Siddhant Rimal
Siddhant Rimal

Reputation: 978

Accessing a method from another method and passing value in Vue

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.

Upvotes: 3

Views: 1915

Answers (1)

kots
kots

Reputation: 465

Use methods rather than computed:

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

Upvotes: 3

Related Questions