一般来说,我对 Buefy、vue 和 javascript 还是很陌生,我正在尝试将分组下拉列表添加到b-taginput
添加autocomplete
似乎启用下拉菜单,但它缺少组。以下是我到目前为止所得到的..
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://unpkg.com/buefy/dist/buefy.min.css">
</head>
<script src="https://unpkg.com/vue"></script>
<script src="https://unpkg.com/buefy/dist/buefy.min.js"></script>
<div id="app">
<b-field label="Tag">
<b-taginput v-model="selected" :data="myDataTags" autocomplete open-on-focus type="is-primary"></b-taginput>
</b-field>
<b-field label="Group">
<b-select placeholder="Select a character">
<optgroup v-for="(option, key) in myData" v-bind:label="key">
<option v-for="opt in option">
{{ opt }}
</option>
</optgroup>
</b-select>
</b-field>
</div>
new Vue({
el: "#app",
data: {
selected: [],
myData: {
'First': ['One', 'Two'],
'Second': ['Three']
}
},
computed: {
myDataTags() {
var items = [];
for (var key in this.myData) {
if (this.myData.hasOwnProperty(key)) {
var obj = this.myData[key];
for (var prop in obj) {
items.push(obj[prop]);
}
}
}
return items;
}
}
})
我的小提琴:https ://jsfiddle.net/Konnor5092/z8doLt4j/124/
我添加了一个b-select
我希望我的b-taginput
下拉列表显示的方式。
我能做些什么来实现这一目标?
谢谢,