使用iview实现某些组件时报错Failed to execute removeChild on Node

完整错误

使用iview实现某些组件时报错Failed to execute removeChild on Node

出现场景

在用iview实现tree组件实现编辑的功能时出现
使用iview实现某些组件时报错Failed to execute removeChild on Node
使用iview实现某些组件时报错Failed to execute removeChild on Node
使用iview实现某些组件时报错Failed to execute removeChild on Node

添加子节点和修改子节点时报错

分析原因

报错位置,iview.js的这个函数
说明this.$el判断有问题
错误意思是删除一个node,但是它不是body的子node
使用iview实现某些组件时报错Failed to execute removeChild on Node

解决办法

document.body.contains改写函数,先来判断是不是body的子node,然后删除
使用iview实现某些组件时报错Failed to execute removeChild on Node