singleton.vue 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <template>
  2. <div>
  3. <el-button v-for="i in 3" :key="i" @mouseover="e => (buttonRef = e.currentTarget)" @click="visible = !visible">Click to open tooltip</el-button>
  4. </div>
  5. <el-tooltip
  6. ref="tooltipRef"
  7. v-model:visible="visible"
  8. :popper-options="{
  9. modifiers: [
  10. {
  11. name: 'computeStyles',
  12. options: {
  13. adaptive: false,
  14. enabled: false,
  15. },
  16. },
  17. ],
  18. }"
  19. :virtual-ref="buttonRef"
  20. virtual-triggering
  21. trigger="click"
  22. popper-class="singleton-tooltip"
  23. >
  24. <template #content>
  25. <span> Some content </span>
  26. </template>
  27. </el-tooltip>
  28. </template>
  29. <script setup lang="ts">
  30. import { ref } from 'vue'
  31. const buttonRef = ref()
  32. const tooltipRef = ref()
  33. const visible = ref(false)
  34. </script>
  35. <style>
  36. .singleton-tooltip {
  37. transition: transform 0.3s var(--el-transition-function-fast-bezier);
  38. }
  39. </style>