[Solved] Cannot read property ‘setCheckedKeys‘ of undefined“

Elementui reports an error. Cannot read property ‘setcheckedkeys’ of undefined“

Click the tree node and execute the following code. An error will be reported because the DOM element is not loaded

  handleRowClick(row) {
    this.$refs.tree.setCheckedKeys(ids);
  },

Correct writing:

  handleRowClick(row) {
    this.$nextTick(() => {
      this.$refs.tree.setCheckedKeys(ids);
    })
  },


Read More: