About the life cycle of vue

clipboard.png

this is elementUI"s tree control

the selected value is the

passed to me in the background.
//mounted:
    axios.get("/adSquad/findById",{
        params:{
            id:this.currentID
        }
    })
    .then(res=>{
                this.$refs.tree_Interests.setCheckedKeys(res.data.data.interest); //
            }
    })

the browser hints: "setCheckedKeys" of undefined
on second thought, it should be a life cycle problem. The tree control is assigned before it is loaded, and it prompts undefined. So is there a way to request background data after the page is loaded?


so is there a way to request background data after the page is loaded?
that can be done in mounted . For questions like
, I think we should look at the Vue documentation. If you don't understand the document, or it's not written in the document, it's better to ask questions again.

// dom
mounted(){
    // [`$nextTick`](https://cn.vuejs.org/v2/api/-sharpvm-nextTick)`API`
    this.$nextTick(() => {
        // code here
    });
}

this.$nextTick(()={
    this.$refs.tree...
})
Menu