fix types error of MkContextMenu

This commit is contained in:
Lhcfl 2024-04-10 23:36:42 +08:00
parent 909125e519
commit 43aeec32ce

View file

@ -28,7 +28,7 @@ const emit = defineEmits<{
(ev: "closed"): void; (ev: "closed"): void;
}>(); }>();
const rootEl = ref<HTMLDivElement>(); const rootEl = ref<HTMLDivElement | null>(null);
const zIndex = ref<number>(os.claimZIndex("high")); const zIndex = ref<number>(os.claimZIndex("high"));
@ -36,8 +36,8 @@ onMounted(() => {
let left = props.ev.pageX + 1; // + 1 let left = props.ev.pageX + 1; // + 1
let top = props.ev.pageY + 1; // + 1 let top = props.ev.pageY + 1; // + 1
const width = rootEl.value.offsetWidth; const width = rootEl.value!.offsetWidth;
const height = rootEl.value.offsetHeight; const height = rootEl.value!.offsetHeight;
if (left + width - window.scrollX > window.innerWidth) { if (left + width - window.scrollX > window.innerWidth) {
left = window.innerWidth - width + window.scrollX; left = window.innerWidth - width + window.scrollX;
@ -55,8 +55,8 @@ onMounted(() => {
left = 0; left = 0;
} }
rootEl.value.style.top = `${top}px`; rootEl.value!.style.top = `${top}px`;
rootEl.value.style.left = `${left}px`; rootEl.value!.style.left = `${left}px`;
document.body.addEventListener("mousedown", onMousedown); document.body.addEventListener("mousedown", onMousedown);
}); });