2017-08-17 78 views
0

我是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') 

我已經設置了 「組標籤」,但它仍然顯示 「未定義」。

有沒有人有想法是什麼問題?提前致謝!

enter image description here

鏈接代碼: https://codepen.io/dennis-leeyinghui/pen/VzybrR

回答

2

它已經固定here問題,

與此,而不是取代你的vue-select

https://unpkg.com/[email protected]/dist/vue-multiselect.min.js 
+0

太棒了!謝謝!!!!!!!!!!!!! –

+0

我將您的示例移至此處,它正在工作:https://jsfiddle.net/pqjww0me/8/ – kevguy

1

應該a bug fixed in v2.0.2,你的代碼最新VUE,多選打得很好。
檢查webpackbin here

+0

謝謝!第一次遇到bug lol你認爲CodePen中有什麼我可以解決的問題嗎? –

+0

kevlai22已經指出了。只需使用'https:// unpkg.com/vue-multiselect @ 2.0.0-beta.15/dist/vue-multiselect.min.js' – choasia

+0

我從kevlai22得到了答案。非常感謝:D –