解决nuxt3报错: Failed to execute ‘insertBefore‘ on ‘Node‘: The node before which the new node is to be i

问题描述:NUXT3项目切换页面跳转控制台报错,页面不显示:

Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.

 

翻译过来的意思是:在“Node”上执行“insertBefore”失败:要插入新节点的节点不是此节点的子节点。

在官网查了一下发现了问题所在: 官网

Pages must have a single root element to allow route transitions between pages. HTML comments are considered elements as well.

This means that when the route is server-rendered, or statically generated, you will be able to see its contents correctly, but when you navigate towards that route during client-side navigation the transition between routes will fail and you'll see that the route will not be rendered.

 

翻译:页面必须有一个根元素,以允许页面之间的路由转换。HTML注释也被视为元素。
这意味着,当路由由服务器渲染或静态生成时,您将能够正确查看其内容,但当您在客户端导航期间导航到该路由时,路由之间的转换将失败,您将看到路由不会被渲染。

解决办法:路由对应的页面确保有一个根元素!!!

虽然Vue3 支持多个根元素,但在 Nuxt3 里面,如果进入多根元素页面,再跳转去其他页面,会导致页面空白,控制台会报上面的错误。

请避坑

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值