vue在同一個組件內;方法之間經常需要互相調用。
methods中的一個方法如何調用methods中的另外一個方法呢?
可以在調用的時候使用 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的方法
}
}
})