Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用keepalive+suspense缓存asyncsetup组件时切换过快就会报错null of parentNode #5993

Closed
lopck opened this issue May 24, 2022 · 7 comments

Comments

@lopck
Copy link

lopck commented May 24, 2022

Vue version

3.2.36

Link to minimal reproduction

https://github.com/lopck/vue3-test

Steps to reproduce

Loading-routers...
在这里如果等一个组件加载完再切换其他的组件不会出问题,但是如果组件还没加载完成就切换到其他的组件,多点几次就会出问题,就是快速的来回切换多个组件就会触发这个bug

What is expected?

如果组件还没加载完就切换应该是在后台继续加载,然后切换到你新的组件

What is actually happening?

在这里如果等一个组件加载完再切换其他的组件不会出问题,但是如果组件还没加载完成就切换到其他的组件,多点几次就会出问题,就是快速的来回切换多个组件就会触发这个bug

System Info

runtime-dom.esm-bundler.js?2725:35 
        
       Uncaught (in promise) TypeError: Cannot read properties of null (reading 'parentNode')
    at parentNode (runtime-dom.esm-bundler.js?2725:35:1)
    at ReactiveEffect.componentUpdateFn [as fn] (runtime-core.esm-bundler.js?d2dd:5124:1)
    at ReactiveEffect.run (reactivity.esm-bundler.js?89dc:185:1)
    at updateComponent (runtime-core.esm-bundler.js?d2dd:4983:1)
    at processComponent (runtime-core.esm-bundler.js?d2dd:4916:1)
    at patch (runtime-core.esm-bundler.js?d2dd:4504:1)
    at patchBlockChildren (runtime-core.esm-bundler.js?d2dd:4821:1)
    at patchElement (runtime-core.esm-bundler.js?d2dd:4729:1)
    at processElement (runtime-core.esm-bundler.js?d2dd:4584:1)
    at patch (runtime-core.esm-bundler.js?d2dd:4501:1)

Any additional comments?

No response

@lopck lopck changed the title 使用keepalive+suspense缓存组件时切换过快就会触发 使用keepalive+suspense缓存asyncsetup组件时切换过快就会报错null of parentNode May 26, 2022
@liulinboyi
Copy link
Member

希望提供一个最小的复现。

@723386252
Copy link

尝试在keepalive中加入include解决问题

@KyrieY
Copy link

KyrieY commented Sep 30, 2022

我想问一下



这样使用时并没有生效

@723386252
Copy link

我想问一下 这样使用时并没有生效

include数组需要加入组件名,而不是路由名

@Flysky12138
Copy link

使用 Nuxt3 时遇到同样的问题。我的 script 块中有个 await useFetch 请求,当请求未完成(即:组建未加载完成),切换走,再切换回来,就会出现同样的问题。

@favouredddd
Copy link

对组件包一层div可以解决这个问题。

@edison1105
Copy link
Member

duplicate of #6463

@github-actions github-actions bot locked and limited conversation to collaborators Jan 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants