[Solved] 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 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: