本文主要是介绍el-popover设置 :visible 手动关闭弹窗后,无法点击空白处关闭弹窗。,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
<script setup lang="ts">
import { ref, unref } from "vue";
import { ClickOutside as vClickOutside } from "element-plus";const popoverShow = ref(false); //是否显示
const popoverRef = ref();/**点击空白处隐藏 */
const onClickOutside = (e: any) => {if (popoverShow.value &&!unref(popoverRef).popperRef.contentRef.contains(e.target)) {popoverShow.value = false;}
};/**提交方法 */
function submit() {console.log("提交成功");
}
</script>
<template><el-popoverplacement="bottom":width="160":visible="popoverShow"ref="popoverRef"><div class="mt-10" style="text-align: right; margin: 0"><div>文本内容</div><el-button size="small" text @click="popoverShow = false">取消</el-button><el-button size="small" type="primary" @click="submit()">确认</el-button></div><template #reference><el-buttontype="primary"@click="popoverShow = true"v-click-outside="onClickOutside">open</el-button></template></el-popover>
</template>
这篇关于el-popover设置 :visible 手动关闭弹窗后,无法点击空白处关闭弹窗。的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!