JohnnyChan 2 kuukautta sitten
vanhempi
commit
dc67b40604
1 muutettua tiedostoa jossa 33 lisäystä ja 0 poistoa
  1. 33 0
      JLHWEB/src/components/LjPopover/index.vue

+ 33 - 0
JLHWEB/src/components/LjPopover/index.vue

@@ -0,0 +1,33 @@
+<template>
+  <el-popover ref="popoverRef" :virtual-ref="buttonRef" :visible="hidePopover" virtual-triggering v-bind="$attrs">
+    <div v-click-outside="close">
+      <slot name="default"></slot>
+    </div>
+  </el-popover>
+</template>
+
+<script setup lang="ts">
+import { ref, unref } from "vue";
+import { ClickOutside as vClickOutside } from "element-plus";
+
+const buttonRefs = ref([]);
+const buttonRef = ref();
+const popoverRef = ref();
+const hidePopover = ref(false);
+const close = () => {
+  hidePopover.value = false;
+};
+/**
+ * @description 显示popover
+ * @param {HTMLElement} data ref对象
+ */
+const show = data => {
+  buttonRef.value = data;
+  hidePopover.value = true;
+};
+
+defineExpose({
+  show,
+  close
+});
+</script>