设置一个隐藏
1、:ref="`popover-${row.id}`
2、const key = "popover-" + id
this.$nextTick(() => {
document.getElementById(this.$refs[key].$refs.popper.id).style.display =
"none"
})
完整代码:
<el-popover placement="bottom" title="编辑标签" width="400" trigger="manual" v-model="row.tagVisible"
:ref="`popover-${row.id}`">
<div class="close-icon">
<i class="el-icon-circle-close" @click="handleTagShow(row.id)"></i>
</div>
<el-tag :key="tag.id" v-for="tag in row.portalDatasetsTagList" closable
:disable-transitions="false" style="margin-right:8px;margin-bottom:8px;"
@close="handleClose(tag)">
{{tag.tagName}}
</el-tag>
<el-select v-if="inputVisible" v-model="inputValue" ref="saveTagInput" filterable allow-create
default-first-option placeholder="请选择标签" @change="handleInputConfirm">
<el-option v-for="item in options" :key="item.id" :label="item.tagName" :value="item.id">
</el-option>
</el-select>
<el-button v-else class="button-new-tag" size="small" @click="showInput" :loading="addLoading">+
标签
</el-button>
<el-button type="text" slot="reference" @click="handleTagShow(row.id)">
{{buttonLabel}}
</el-button>
</el-popover>
handleTagShow(id) {
this.row.tagVisible = !this.row.tagVisible
const key = "popover-" + id
this.$nextTick(() => {
document.getElementById(this.$refs[key].$refs.popper.id).style.display =
"none"
})
}
本文介绍了一种使用Vue.js实现Popover组件隐藏效果的方法。通过设置ref属性来引用元素,并利用Vue的生命周期函数$nextTick来确保DOM更新后执行隐藏操作。文章详细展示了如何通过JavaScript操作DOM的display样式达到隐藏目的。

2677

被折叠的 条评论
为什么被折叠?



