Failed to execute ‘insertBefore‘ on ‘Node‘: The node before which the new node is to ...报错

今天遇到了

Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node. at Object.vi [as insertBefore]

这个报错,使用场景:

框架使用的是若依前端框架,在使用按钮权限时,报了这个错。

  <el-button  type="text"  size="small"  v-if="scope.row.contractStatus === 10" 
      v-hasPermi="['contract:sign', 'contract:signB']">编辑</el-button >

在判断权限的同时,使用的v-if,于是报了这个错。

检查元素发现 若依框架v-hasPermi 是使用的display:none,在v-if为false时。

        如果我们后续的js操作了v-if控制的dom元素,将会因为该部分dom元素不存在而抛出上述异常。

所以,将v-if改成v-show就可以了


版权声明:本文为Lora_0925原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。