美文网首页
vue中methods的互相调用

vue中methods的互相调用

作者: zjh111 | 来源:发表于2018-10-30 10:52 被阅读0次
    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的互相调用

          本文链接:https://www.haomeiwen.com/subject/ghowtqtx.html