vue methods 方法中 方法 調用 另一個方法。


vue在同一個組件內;

methods中的一個方法調用methods中的另外一個方法。

可以在調用的時候 this.$options.methods.test();

this.$options.methods.test2();一個方法調用另外一個方法;

 

new Vue({
    el: '#app',
  data: {
      test:111,
  },
  methods: {
      test1:function(){
            alert(this.test)
        },
        test2:function(){
            alert("this is test2")
            alert(this.test) //test3調用時彈出undefined
        },
        test3:function(){
            this.$options.methods.test2();//在test3中調用test2的方法
        }
  }
})

 


免責聲明!

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



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