vue.esm.js?efeb:591 [Vue warn]: Error in event handler for “click”: “TypeError: Cannot read property ‘setCheckedKeys’ of undefined”
This is because this.dialogVisible = true does not update the dom immediately, but waits for the entire logic to be executed and then renders it again, so the popup box is not rendered at this time and does not exist in the dom tree.
This.$refs.tree is undefined so setCheckedKeys must also be undefined.
Solution: Use this.$nextTick(), this.$nextTick() will execute callback after DOM update:
opetation (auth) {
this.dialogVisible = true
this.$nextTick(function() {
this.$refs.tree.setCheckedKeys(auth)
})
}
Read More:
- [Solved] Element form method resetfields() error: vue.runtime.esm.js?2b0e:1888 TypeError: Cannot read properties of undefined (reading ‘indexOf’)
- [Solved] Error in v-on handler “TypeError Cannot read properties of undefined (reading ‘resetFields‘)“
- Vue form validate error: Error in v-on handler “TypeError Cannot read properties of undefined (reading ‘indexOf‘)
- JS bug Log Uncaught TypeError: Cannot read property ‘previoustSibling‘ of null
- [Solved] Vue Error: TypeError: Cannot read property ‘end‘ of undefined
- [Solved] Cannot read property ‘setCheckedKeys‘ of undefined“
- [Solved] Binding onclick event in JS: for loop: error uncaught typeerror: cannot set properties of undefined (setting ‘classname’)
- [Solved] Error in callback for watcher “value“: “TypeError: Cannot read property ‘level‘ of null“
- Uni-app Error when assigning a value to a component: [system] TypeError: Cannot read property ‘name‘ of undefined
- [Solved] Syntax Error: TypeError: Cannot read property ‘parseComponent‘ of undefined
- [Solved] Syntax Error: TypeError: Cannot read property ‘parseComponent‘ of undefined
- [Solved] electron Error: Uncaught TypeError: Cannot read property ‘BrowserWindow‘ of undefined
- [Solved] vue watch Error: Error in callback for watcher “xxx“: “TypeError: Cannot read properties of undefined …
- [Solved] Uni.createintersectionobserver Error: Uncaught TypeError: Cannot read property ‘bottom’ of null
- [Solved] VUE Error: Error in mounted hook: “TypeError: Cannot read properties of undefined (reading ‘$on‘)“
- [Solved] Vue element UI form verification error: cannot read property ‘validate’ of undefined
- Vue cannot read property ‘xxx’ of undefined solutions
- uniapp Use render Function Error: [Vue warn]: Error in beforeCreate hook: “TypeError: Cannot read property ‘_i‘ of
- [Solved] Vue Project Error: “TypeError: Cannot read properties of undefined (reading ‘init‘)“
- [Solved] Install The Latest Version of Jest Error: TypeError: Cannot read property ‘instrument‘ of undefined