Vue Multiselect:访问对象内的自定义选项对象
Vue Multiselect: Access object within object for custom option
我正在使用 Vue Multiselect Custom Option Template
我想使用名称 属性 作为 customLabel
通常这会很容易,就像使用 name
但在这种情况下,我需要的 属性 在另一个对象中。
这是我带来的对象:
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
通常 name 位于根目录中,因此很容易访问,但我需要访问嵌套在 profile
下的 profile_name
这是我目前尝试过的方法:
methods: {
customLabel ({ profile['profile_name'] }) {
return `${ profile['profile_name'] }`
}
这会起作用:
methods: {
customLabel ({ profile }) {
return `${ profile.profile_name }`
}
我正在使用 Vue Multiselect Custom Option Template
我想使用名称 属性 作为 customLabel
通常这会很容易,就像使用 name
但在这种情况下,我需要的 属性 在另一个对象中。
这是我带来的对象:
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
通常 name 位于根目录中,因此很容易访问,但我需要访问嵌套在 profile
profile_name
这是我目前尝试过的方法:
methods: {
customLabel ({ profile['profile_name'] }) {
return `${ profile['profile_name'] }`
}
这会起作用:
methods: {
customLabel ({ profile }) {
return `${ profile.profile_name }`
}