项目场景:nuxt 线上刷新页面后不显示问题
问题描述
线上刷新打开控制台报这个错误
Failed to execute 'appendChild' on 'Node': This node type does not support this method...
原因分析:
1.组件在客户端刷新页面没渲染
2.排查问题打开控制台看是否出现以下错误
[Vue 警告]:渲染错误:“ReferenceError:文件未定义”[Vuetify + NuxtJS]
3.查看.vue文件是否引入组建
解决方案:
<client-only /> 此组件用于仅在客户端渲染其他组件. <template> <div> <sidebar /> <client-only placeholder="Loading..."> <!-- comments 组件只会在客户端被渲染 --> <comments /> </client-only> </div> </template>
在组件外层写入<client-only></<client-only>,重新打开部署,刷新页面,页面不会丢失