element ui select 点击option里的按钮,如何禁止他自动收起?
请教需求:点击删除按钮的时候,这个下拉框禁止他自动收起
<template>
<div class="app-container home">
<el-select
v-model="value"
@change="handleTagChange"
filterable
ref="configSelect"
>
<el-option
v-for="tag in userTags"
:key="tag.id"
:label="tag.label"
:value="tag.name"
>
<span style="float: left">{{ tag.label }}</span>
<el-tag
v-if="true"
size="mini"
effect="dark"
type="danger"
style="float: right; margin-top: 8px; margin-left: 3px"
@click.stop="handleDeleteTag(tag.name, $event)"
>
删除
</el-tag>
</el-option>
</el-select>
</div>
</template>
<script>
export default {
name: "Index",
data() {
return {
userTags: [
{
name: "1",
label: "黄金糕",
},
{
name: "2",
label: "双皮奶",
},
{
name: "3",
label: "螺蛳粉",
}
],
value: "",
};
},
methods: {
handleTagChange(e){
console.log(e)
},
handleDeleteTag (tag) {
this.$refs.configSelect.visible = false
this.$confirm('确认删除', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$refs.configSelect.visible = false
// console.log(tag.id)
this.userTags = this.userTags.filter((v,i)=>{
return tag != v.name
})
})
}
},
};
</script>
回复
1个回答
适合作为回答的
- 经过验证的有效解决办法
- 自己的经验指引,对解决问题有帮助
- 遵循 Markdown 语法排版,代码语义正确
不该作为回答的
- 询问内容细节或回复楼层
- 与题目无关的内容
- “赞”“顶”“同问”“看手册”“解决了没”等毫无意义的内容