我是Vue的新手,並從各種教程中改進了這些代碼。Vue-Multiselect中的「未定義」組標籤?
但是,我在這裏遇到了這個「未定義」的組名問題。
的.html:
<multiselect
v-model="value"
:options="options"
:multiple="true"
track-by="name"
:hide-selected="true"
:custom-label="customLabel"
:searchable="false"
placeholder=""
group-values="details"
group-label="groupDivision"
>
</multiselect>
的.js:
new Vue({
components: {
Multiselect: VueMultiselect.default
},
data: {
value: { groupDivision: 'Government',
name: 'Fish',
contact: '[email protected]' },
options: [
{
groupDivision: 'Governemnt',
details:[
{ name: 'Fish', contact: '[email protected]' },
{ name: 'Police', contact: '[email protected]' },
{ name: 'Society', contact: '[email protected]' }
]
},
{
groupDivision: 'Media',
details:[
{ name: 'BBC', contact: '[email protected]' },
{ name: 'CNN', contact: '[email protected]' },
{ name: 'CBC', contact: '[email protected]' }
]
},
]
},
methods: {
customLabel (option) {
return `${option.name}`
}
}
}).$mount('#app')
我已經設置了 「組標籤」,但它仍然顯示 「未定義」。
有沒有人有想法是什麼問題?提前致謝!
鏈接代碼: https://codepen.io/dennis-leeyinghui/pen/VzybrR
太棒了!謝謝!!!!!!!!!!!!! –
我將您的示例移至此處,它正在工作:https://jsfiddle.net/pqjww0me/8/ – kevguy