singleton.vue 951 B

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