这个是elementUI的tree控件
被选上的值是后台传给我的
//mounted生命中期中的代码:
axios.get('/adSquad/findById',{
params:{
id:this.currentID
}
})
.then(res=>{
this.$refs.tree_Interests.setCheckedKeys(res.data.data.interest); //设置被选中
}
})
浏览器提示了:'setCheckedKeys' of undefined
想了下,应该是生命周期的问题。tree控件还没加载出来就被赋值了,就会提示undefined。所以有没有方法等页面加载完成后去请求后台数据?
所以有没有方法等页面加载完成后去请求后台数据?
那可以放在
mounted
里去做。这类问题我觉得应该去看
Vue
文档。文档没看懂,或者文档中没有写,再来提问比较好。