vue:如果this.$refs.xxx報錯訪問不到


在標簽里面寫了個ref="table1",然后js里使用this.$refs.table1訪問報錯:Cannot read properties of undefined (reading '$refs')

 

 

解決辦法:放到this.$nextTick(function(){});函數里使用,就可以訪問到了

this.$nextTick(function(){
    console.log(this.$refs.table1);
    this.$refs.table1.lazy=true
});

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM