今天遇到了

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就可以了

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐