vue3.2 elementplus 中 popover组件指定按钮触发
<template>
<el-button type="primary" @click="(e:any)=>showLogin(e)" > 指定触发按钮 </el-button >
<el-popover
v-if="popVisible"
placement="bottom"
:width="300"
trigger="click"
v-model:visible="popVisible"
virtual-triggering
:virtual-ref="tempRef"
:show-arrow="false"
popper-class="pop-class"
>
我是content
</el-popover>
</template>
<script lang="ts" setup>
import {ref,unref,nextTick} from 'vue'
const popVisible= ref<boolean>(false);
const tempRef = ref()
const showLogin = (e:any)=>{
const evt = e || (window as any).e || (window as any).event;
if (unref(tempRef) && unref(tempRef).tempRef) popVisible.value = false
nextTick(() => {
tempRef.value = evt.currentTarget
popVisible.value = true
})
}
</script>