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       },
原文地址:https://www.cnblogs.com/wzbk/p/10308206.html