< 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>