Vue頁面加載時,觸發某個函數的方法


需要在加載頁面的時候調用生成驗證碼的click事件函數

解決方法如下,利用Vue中的mounted

 

 1 mounted:function(){
 2       this.createcode();//需要觸發的函數
 3     }
 4 //下面是createcode函數
 5  createcode(){
 6         var self = this;
 7         axios.post("/verifycode",{name:this.name,id:this.id}).then(function(res){
 8           //console.log(res);
 9           var url= JSON.parse(res.data.code64);
10           //console.log(url)
11           self.urlIMg  = url.data.base64Code;
12  
13         });
14       },

 


免責聲明!

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



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