elementUI el-tree报错 Cannot read property ‘setCheckedKeys’ of undefined"
给树节点赋值时,执行下面代码会报错,原因是:DOM元素未加载完成.
以下为错误写法。
handleRowClick(row)
{ this.$refs.tree.setCheckedKeys(ids); }
handleRowClick(row)
{
this.$nextTick(() =>{
this.$refs.tree.setCheckedKeys(ids);
})
以上为正确写法,属于延迟回掉,但是也可能会报以上错误,还是在dom未加载完成。
SetTimeout(()=>{
this.$refs.tree.setCheckedKeys(ids);
})
本文来自博客园,作者:zwbsoft,转载请注明原文链接:https://www.cnblogs.com/zwbsoft/p/16401186.html
电话微信:13514280351