vue中methods的互相调用

new Vue({
    el: '#app',
  data: {
      test:1,
  },
  methods: {
      test1:function(){
            alert(this.test)
        },
        test2:function(){
            this.$options.methods.test1();
        }
  }
})

通过this.$options.methods来查找要调用的methods中的函数。一些时候this的指向不同需要使用bind(this)。

你可能感兴趣的:(vue中methods的互相调用)