How to pass parameters in computed properties in Vue.Js?

Answer • 1 Asked • Jul 6 2019
Is this possible to pass parameter in computed properties in Vue.Js. I can see when having getters/setter using computed, they can take a parameter and assign it to a variable. like here from documentation:
// ... computed: { fullName: { // getter get: function () { return this.firstName + ' ' + this.lastName }, // setter set: function (newValue) { var names = newValue.split(' ') this.firstName = names[0] this.lastName = names[names.length - 1] } } } // ...

Is this also possible:
// ... computed: { fullName: function (salut) { return salut + ' ' + this.firstName + ' ' + this.lastName } } // ...

Where computed property takes a argument and returns desired output. However when I try this, I am getting this error:
vue.common.js:2250 Uncaught TypeError: fullName is not a function(…)
Should I be using methods for such cases?

Write your answer...

On a mission to build Next-Gen Community Platform for Developers