使用elementUI時,tree遇到的坑html
一、
發現,this.$refs每次都是undefined;
問題緣由:渲染組件須要時間,而且時間沒有JS執行的快;因此獲取不到
解決辦法:第一種利用setTimeoutthis
this.condition = true;
setTimeout(()=>{htm
},0)
2,
第二種:利用 this.$nextTickblog
this.condition = true;
this.$nextTick(()=>{
this.$refs.tree.setCheckedKeys(role.permissions)
})element
PS:另外附上 setTimeout爲0時的做用與意義 https://www.cnblogs.com/yhl-0822/p/9835588.htmlit
------------------------------------------------------
做者:小牧臨風(一個懵懵懂懂的萌新碼農)io