报错问题
Nuxt.js打包后报错
DOMException: Failed to execute 'appendChild' on 'Node': This node type does not support this method.
开发环境下报错
Mismatching childNodes vs. VNodes:
解决
1、template中可以限制只在客户端渲染
// version >= 2.9.0 <client-only></client-only> // version < 2.9.0 <no-ssr></no-ssr>
参考
- Failed to execute ‘appendChild’ on ‘Node’: This node type does not support this method.
- https://nuxtjs.org/api/components-client-only/
2、script中可以使用客户端、服务端判断
if(process.client){ console.log('client') } if(process.server){ console.log('server') }
参考