vue.esm.js?efeb:591 [Vue warn]: Error in event handler for “click“: “TypeError: Cannot read property
vue.esm.js?efeb:591 [Vue warn]: Error in event handler for "click": "TypeError: Cannot read property 'setCheckedKeys' of undefined"相信很多人遇到过这个问题,这是因为this.dialogVisible = true时并没有立即更新dom,而是等整个逻辑执行完后再一次新
·
vue.esm.js?efeb:591 [Vue warn]: Error in event handler for "click": "TypeError: Cannot read property 'setCheckedKeys' of undefined"
相信很多人遇到过这个问题,这是因为this.dialogVisible = true时并没有立即更新dom,而是等整个逻辑执行完后再一次新渲染,因此此时的弹框并未渲染,在dom树中是不存在的,
this.$refs.tree is undefined的所以setCheckedKeys肯定也是undefined。
解决方法: this.$nextTick(),this.$nextTick()会在dom更新之后再执行回调:
opetation (auth) {
this.dialogVisible = true
this.$nextTick(function() {
this.$refs.tree.setCheckedKeys(auth)
})
}
更多推荐
已为社区贡献1条内容
所有评论(0)