vue中「methods、computed」一個方法調用另一個方法

vue在同一個組件內;vue

methods中的一個方法調用methods中的另一個方法bash

能夠在調用的時候 this.$options.methods.test2();app

一樣適用於:this.$options.computedui

示例:this

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的方法        }  }複製代碼
相關文章
相關標籤/搜索