How to Pass Parameters in Computed Properties in Vue.js

If you wonder whether it is possible to pass parameter in computed properties in Vue.js or not, you should read this tutorial.

Most probably you will want a method for doing it:

<span>{{ fullName('Hi') }}</span>

methods: {
  fullName(salut) {
      return `${salut} ${this.firstName} ${this.lastName}`

However, you can use a computed property with a parameter like this:

computed: {
   fullName() {
      return salut => `${salut} ${this.firstName} ${this.lastName}`

Computed Properties

Computed properties are used to calculate the properties which are displayed in the view. These calculations will be cached and will only update if necessary. The difference between computed properties and a method is the computed properties are cached and change only when their dependencies change. A method will evaluate every time it is invoked.