vue中的报错 The node before which the new node is to be inserted is not a child of this node.

清疚 2021-09-02 06:14 496阅读 0赞

The node before which the new node is to be inserted is not a child of this node.

今天上线打完包在线上跑,点击element的下拉筛选框突然卡死,控制台报上面的错误

  1. vendors~app.f874c403.js:58 DOMException: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.

经资料查询发现,导致上述异常是因为在html中使用了v-if来控制局部显隐导致的。

解释:

页面用了v-if去控制dom元素,之后js操作了v-if控制的dom元素而导致的报错,可以用v-show,只是display:none元素,就不会抛出异常

发表评论

表情:
评论列表 (有 0 条评论,496人围观)

还没有评论,来说两句吧...

相关阅读