directive.ts 544 B

123456789101112131415161718192021
  1. import type { DirectiveBinding, ObjectDirective } from 'vue'
  2. import type { PopoverInstance } from './popover'
  3. const attachEvents = (el: HTMLElement, binding: DirectiveBinding) => {
  4. const popperComponent: PopoverInstance = binding.arg || binding.value
  5. const popover = popperComponent?.popperRef
  6. if (popover) {
  7. popover.triggerRef = el
  8. }
  9. }
  10. export default {
  11. mounted(el, binding) {
  12. attachEvents(el, binding)
  13. },
  14. updated(el, binding) {
  15. attachEvents(el, binding)
  16. },
  17. } as ObjectDirective
  18. export const VPopover = 'popover'