<el-select v-model="valueOne" filterable multiple collapse-tags>
<el-option
v-for="item in selectionOne"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
export default {
data() {
return {
valueOne: [],
selectionOne: [
{
value: "选项1",
label: "黄金糕"
},
{
value: "选项2",
label: "双皮奶"
},
{
value: "选项3",
label: "蚵仔煎"
},
{
value: "选项4",
label: "龙须面"
},
{
value: "选项5",
label: "北京烤鸭"
}
]
};
},
}
网上搜的大部分答案写的
created() {
this.valueOne.push(this.selectionOne[0].label);
this.valueOne.push(this.selectionOne[1].label);
}
效果图
前两选依然可以打勾选中
修改为
created() {
this.valueOne.push(this.selectionOne[0].value);
this.valueOne.push(this.selectionOne[1].value);
}
效果图