fix: setContainer in onBeforeMount for drawer (#6986)
* fix: setContainer in onBeforeMount for drawer * fix: add judgementpull/7025/head
parent
4428423be4
commit
449adb03df
|
@ -23,14 +23,24 @@ export default defineComponent({
|
|||
// getContainer 不会改变,不用响应式
|
||||
let container: HTMLElement;
|
||||
const { shouldRender } = useInjectPortal();
|
||||
onBeforeMount(() => {
|
||||
isSSR = false;
|
||||
});
|
||||
onMounted(() => {
|
||||
|
||||
function setContainer() {
|
||||
if (shouldRender.value) {
|
||||
container = props.getContainer();
|
||||
}
|
||||
}
|
||||
|
||||
onBeforeMount(() => {
|
||||
isSSR = false;
|
||||
// drawer
|
||||
setContainer();
|
||||
});
|
||||
onMounted(() => {
|
||||
if (container) return;
|
||||
// https://github.com/vueComponent/ant-design-vue/issues/6937
|
||||
setContainer();
|
||||
});
|
||||
|
||||
const stopWatch = watch(shouldRender, () => {
|
||||
if (shouldRender.value && !container) {
|
||||
container = props.getContainer();
|
||||
|
|
|
@ -90,8 +90,7 @@ const Holder = defineComponent({
|
|||
closable: false,
|
||||
closeIcon: mergedCloseIcon,
|
||||
duration: props.duration ?? DEFAULT_DURATION,
|
||||
getContainer: () =>
|
||||
props.staticGetContainer?.() || getPopupContainer.value?.() || document.body,
|
||||
getContainer: props.staticGetContainer ?? getPopupContainer.value,
|
||||
maxCount: props.maxCount,
|
||||
onAllRemoved: props.onAllRemoved,
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue