我一直在实现最新的 Vue-Multiselect 并让它在页面中呈现出来。由于某种原因,该v-model
值似乎没有生效,因为它保持为空。
import { Multiselect } from 'vue-multiselect'
var MultiSelect = Vue.extend({
components: { Multiselect },
template: '<div><multiselect :options="options" :multiple="true" :close-on-select="false" :clear-on-select="false" :hide-selected="true" placeholder="Please select..." label="name" track-by="name"></multiselect></div>',
data: function() {
return {
value: [],
options: []
};
}
});
Vue.component('multi-select', MultiSelect);
我正在按照示例设置所有选项:
options: [
{
language: 'Javascript',
libs: [
{ name: 'Vue.js', category: 'Front-end' },
{ name: 'Adonis', category: 'Backend' }
]
},
{
language: 'Ruby',
libs: [
{ name: 'Rails', category: 'Backend' },
{ name: 'Sinatra', category: 'Backend' }
]
},
{
language: 'Other',
libs: [
{ name: 'Laravel', category: 'Backend' },
{ name: 'Phoenix', category: 'Backend' }
]
}
],
这是刀片中的代码:
<multi-select v-model="updateTutorInstrumentsForm.options" group-values="libs" group-label="language"></multi-select>
<pre>@{{ updateTutorInstrumentsForm.options }}</pre>
至少可以说有点困惑!