首页 > 技术文章 > vue-created调用mothods中的方法

zhlii 2020-11-12 10:58 原文

正常调用可采取以下

created: function() {
       this.$options.methods.loadLinks();
},
methods: {
  loadLinks: function() { 
    
      }    
}    

但是有时候methods方法中需要用到data中数据,由于生命周期原因,可采取如下:

created: function() {
        this.$options.methods.loadLinks.bind(this)("");
},
methods: {
        loadLinks: function() {
            this.currentPage = 1;
        }     		
}

  

 

推荐阅读