Accessing a method from another method and passing value in Vue

时间:2018-09-18 20:13:42

标签: vue.js

I got this.

Now, I wan't to know if this is possible

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

I want to be able to send two arguments (3,2) into function:X and then have the computed result sent back to Y. So far, this has failed. I've read this but it led me nowhere in particular.

1 个答案:

答案 0 :(得分:1)

Use methods rather than computed:

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