Cannot read property 'setCheckedKeys' of undefined

uses the Dialog dialog box of element-ui. There is a Tree tree control in the dialog box that can select the tree node. When I first opened the Dialog and initialized the node of the Tree tree control, I reported an error, Cannot read property "setCheckedKeys" of undefined, and then the second time I opened it, it will not report an error, and the data can be rendered normally. How to solve

Jun.17,2021

the idea goes something like this:

// 
<button @click="update"></button>
<v-tree-dialog :is-show="isShow" ref="treeUpdate" ></v-tree-dialog> 

update() {
  this.isShow= true
  this.$nextTick(() => {
    this.$refs.treeUpdate.init()
  })
}
// 
<el-tree
  :data="treeData"
  show-checkbox
  node-key="id"
  ref="tree"
>
</el-tree>

init() {
 this.$refs.tree.setCheckedKeys([1])
},

I have the same problem, especially when putting tree in form tickles

Menu