2017-08-17 19 views
0

私はVueを初め、このチュートリアルのコードを改善しました。Vue-Multiselectの "Undefined"グループラベル?

しかし、私はこの "未定義"グループ名の問題に直面しています。

の.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/vue-multisel[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

感謝を!初めてバグに遭遇する問題を回避するためにCodePenで何かできることはありますか? –

+0

kevlai22はすでにそれを指摘しました。 'https:// unpkg.com/vue-multiselect @ 2.0.0-beta.15/dist/vue-multiselect.min.js'を使用してください。 – choasia

+0

私はkevlai22から答えを得ました。ありがとう、非常にありがとう:D –