【问题标题】:Accessing a method from another method and passing value in Vue从另一个方法访问一个方法并在 Vue 中传递值
【发布时间】:2019-02-22 22:15:11
【问题描述】:

got这个。

现在,我想知道这是否可能

computed : {
    X: function(a,b){
      return(a*b)
    },
    Y: function(e){
      var c = this.X(3,2)
      return(c)
    }
}

我希望能够将两个参数(3,2) 发送到函数:X,然后将计算结果发送回 Y。到目前为止,这已经失败。我读过this,但它没有让我有什么特别之处。

【问题讨论】:

    标签: vue.js


    【解决方案1】:

    使用方法而不是计算:

    methods: {
        X: function(a,b){
          return(a*b)
        },
        Y: function(e){
          var c = this.X(3,2)
          return(c)
        }
    }
    

    【讨论】:

    • 等等,还有method?我有点需要 Y 来计算。我可以在方法中只使用 X 吗?
    猜你喜欢
    • 2019-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多