Clinton Green
Clinton Green

Reputation: 9977

Vue Multiselect: Access object within object for custom option

I am using the Vue Multiselect Custom Option Template and I want to use the name property as a customLabelnormally this would be easy as just using name but in this case the property I need is within another object.

Here is the object I am bringing in:

0:Object
  created_at:null
  id:1
  profile:Object
    id:1
    picture_url:"some-image.jpg"
    profile_id:"your-id"
    profile_name:"Your Name"
    profile_id:1
  subscription_active:1
  updated_at:null

Normally name would be in the root so it would easy to access but I need to access profile_name which is nested under profile

Here's what I have tried so far:

methods: {
  customLabel ({ profile['profile_name'] }) {
  return `${ profile['profile_name'] }`
}

Upvotes: 0

Views: 895

Answers (1)

flamisz
flamisz

Reputation: 111

This will work:

methods: {
  customLabel ({ profile }) {
  return `${ profile.profile_name }`
}

Upvotes: 1

Related Questions