pirmax
pirmax

Reputation: 2153

VueJS - Object (user.fullName) as property on computed

I search to compute user.fullName with computed() in VueJS 2.

The computed property must be in user object.

computed: {
  'user.fullName': () => {
    return `John Doe`
  }
}

It's doesn't works...

Upvotes: 2

Views: 161

Answers (1)

ndpu
ndpu

Reputation: 22561

You can make user as computed property and dynamically add fullName to it. Real user object should be named differently:

computed: {
  user: () => {
    return {
      ...this.realUserObject,
      fullName: 'John Doe'
    }
  }
}

Upvotes: 4

Related Questions