docs: [tooltip] fix type error (#19687)

* docs: fix type error

* docs: [tooltip] remove unnecessary width and height in mousemove handler

* fix: update

* fix: update
This commit is contained in:
jiaxiang
2025-01-24 15:37:44 +08:00
committed by GitHub
parent fbbb50a9b2
commit d989617162

View File

@ -15,27 +15,24 @@
import { onMounted, onUnmounted, ref } from 'vue' import { onMounted, onUnmounted, ref } from 'vue'
const visible = ref(false) const visible = ref(false)
const triggerRef = ref({
getBoundingClientRect() {
return position.value
},
})
const position = ref({ const position = ref({
top: 0, top: 0,
left: 0, left: 0,
bottom: 0, bottom: 0,
right: 0, right: 0,
} as DOMRect)
const triggerRef = ref({
getBoundingClientRect: () => position.value,
}) })
const mousemoveHandler = (e) => { const mousemoveHandler = ({ clientX, clientY }: MouseEvent) => {
position.value = DOMRect.fromRect({ position.value = DOMRect.fromRect({
width: 0, x: clientX,
height: 0, y: clientY,
x: e.clientX,
y: e.clientY,
}) })
} }
onMounted(() => { onMounted(() => {
document.addEventListener('mousemove', mousemoveHandler) document.addEventListener('mousemove', mousemoveHandler)
}) })