需要在加載頁面的時候調用生成驗證碼的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 },