fix: paginantion error, close #6590
parent
fe3c2bdf89
commit
508e8e3706
|
@ -30,7 +30,7 @@ const getParent = (getContainer: GetContainer) => {
|
||||||
}
|
}
|
||||||
if (getContainer) {
|
if (getContainer) {
|
||||||
if (typeof getContainer === 'string') {
|
if (typeof getContainer === 'string') {
|
||||||
return document.querySelectorAll(getContainer)[0];
|
return document.querySelectorAll(getContainer)[0] as HTMLElement;
|
||||||
}
|
}
|
||||||
if (typeof getContainer === 'function') {
|
if (typeof getContainer === 'function') {
|
||||||
return getContainer();
|
return getContainer();
|
||||||
|
@ -68,9 +68,10 @@ export default defineComponent({
|
||||||
container.value?.parentNode?.removeChild(container.value);
|
container.value?.parentNode?.removeChild(container.value);
|
||||||
container.value = null;
|
container.value = null;
|
||||||
};
|
};
|
||||||
|
let parent: HTMLElement = null;
|
||||||
const attachToParent = (force = false) => {
|
const attachToParent = (force = false) => {
|
||||||
if (force || (container.value && !container.value.parentNode)) {
|
if (force || (container.value && !container.value.parentNode)) {
|
||||||
const parent = getParent(props.getContainer);
|
parent = getParent(props.getContainer);
|
||||||
if (parent) {
|
if (parent) {
|
||||||
parent.appendChild(container.value);
|
parent.appendChild(container.value);
|
||||||
return true;
|
return true;
|
||||||
|
@ -123,11 +124,14 @@ export default defineComponent({
|
||||||
[() => props.visible, () => props.getContainer],
|
[() => props.visible, () => props.getContainer],
|
||||||
([visible, getContainer], [prevVisible, prevGetContainer]) => {
|
([visible, getContainer], [prevVisible, prevGetContainer]) => {
|
||||||
// Update count
|
// Update count
|
||||||
if (supportDom && getParent(props.getContainer) === document.body) {
|
if (supportDom) {
|
||||||
if (visible && !prevVisible) {
|
parent = getParent(props.getContainer);
|
||||||
openCount += 1;
|
if (parent === document.body) {
|
||||||
} else if (init) {
|
if (visible && !prevVisible) {
|
||||||
openCount -= 1;
|
openCount += 1;
|
||||||
|
} else if (init) {
|
||||||
|
openCount -= 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,8 +162,8 @@ export default defineComponent({
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
const { visible, getContainer } = props;
|
const { visible } = props;
|
||||||
if (supportDom && getParent(getContainer) === document.body) {
|
if (supportDom && parent === document.body) {
|
||||||
// 离开时不会 render, 导到离开时数值不变,改用 func 。。
|
// 离开时不会 render, 导到离开时数值不变,改用 func 。。
|
||||||
openCount = visible && openCount ? openCount - 1 : openCount;
|
openCount = visible && openCount ? openCount - 1 : openCount;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue