Nuxt在每次导航时都会对整个应用程序进行硬刷新



我用strapi和nuxt-js构建了一个博客。您可以在后端创建一个URL,前端从该URL动态加载当前数据。当我尝试加载页面时,我会在网络选项卡中弹出404错误,但数据会被加载。

示例页面→https://alphaoptik.net/meine-kamera

我的nuxt配置看起来像:

export default {
ssr: true, // default value
// Global page headers: https://go.nuxtjs.dev/config-head
generate: {
fallback: true
},
loadingIndicator: {
name: 'folding-cube',
color: '#E2C994'
},
head: {
title: 'PageSite',
htmlAttrs: {
lang: 'de'
},
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: '' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
]
},
// Global CSS: https://go.nuxtjs.dev/config-css
css: [],
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
plugins: [
{ src: '~/plugins/vue-unicons', mode: 'client' }
],
// Auto import components: https://go.nuxtjs.dev/config-components
components: true,
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
buildModules: [
// https://go.nuxtjs.dev/typescript
'@nuxt/typescript-build',
// https://go.nuxtjs.dev/tailwindcss
'@nuxtjs/tailwindcss'
],
// Modules: https://go.nuxtjs.dev/config-modules
modules: [
'@nuxtjs/apollo',
'@nuxtjs/cloudinary'
],

target: 'static',
apollo: {
clientConfigs: {
default: '@/apollo/config/config.js'
}
},
cloudinary: {
cloudName: 'cloudName'
},
env: {
strapiBaseUri: process.env.API_URL || "http://localhost:1337"
},
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {}
}

正如OP所说,答案是用<nuxt-link>s替换所有<a>标签(在他的情况下是+SSR和apollo预取(。

现在,这并没有进行任何艰苦的刷新和正常工作。

最新更新