[Vuejs]-No info passing to the modal window from product listing: Error in v-on handler: "TypeError: _vm.selectProduct is not a function"

1👍

As error stated – selectProduct is not a function which itself clears the problem here.

Understand how computed and methods property of vue differs.

Computed
These properties are converted as the vue property with getters and setters which means you can either get a value from it or either set a predefined value, It doesn’t accepts a parameter to it

Ex –

computed : {
  hello() {
    return 'helloWorld' // Getting a value 
  }
}

you will use it as this.hello where as methods which are perfectly a replica of a normal function in JS where with the capabilities of understanding other vue property

methods : {
      hello(name) {
        return 'hello' + name // Getting a value 
      }
    }

As said it’s a fn so it can have parameter also and you can use it as a fn like this.hello(name)

In your case you probably wish to move your selectProduct property to methods property instead as computed property.

Leave a comment