大概功能为动态的删除Row组件中的Col组件,当Col组件被清空的时候,就会出现如上报错,翻阅源码,发现如下问题:
updateGutter(val) {
// 这里会嵌套寻找,把 Col 里的 Row 里的 Col 也找到,所以用 兄弟找
// const Cols = findComponentsDownward(this, 'iCol');
const Col = findComponentDownward(this, 'iCol')
const Cols = findBrothersComponents(Col, 'iCol', false)
if (Cols.length) {
Cols.forEach(child => {
if (val !== 0) {
child.gutter = val
}
})
}
}
在这个函数中:
当 const Col = findComponentDownward(this, 'iCol')
返回的Col 为空时就报错了
解决办法,利用v-if判断,当Col组件为空时,把Row组件也一起删除即可。