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

切换组件报错,可能是transition+keep-alive的问题 #5680

Open
npmrun opened this issue Apr 7, 2022 · 3 comments
Open

切换组件报错,可能是transition+keep-alive的问题 #5680

npmrun opened this issue Apr 7, 2022 · 3 comments

Comments

@npmrun
Copy link

npmrun commented Apr 7, 2022

Version

3.2.27 及以上

Reproduction link

sfc.vuejs.org/

Steps to reproduce

  1. 输入11
  2. 点击切换
  3. 输入 22
  4. 点击前往CC
    然后就报错了,怎么点都报错

What is expected?

正常切换组件

What is actually happening?

切换报错

@npmrun npmrun changed the title 可能是transition+keep-alive的问题 切换组件报错,可能是transition+keep-alive的问题 Apr 7, 2022
@JianJroh
Copy link

Version

3.2.27 及以上

Reproduction link

sfc.vuejs.org/

Steps to reproduce

  1. 输入11
  2. 点击切换
  3. 输入 22
  4. 点击前往CC
    然后就报错了,怎么点都报错

What is expected?

正常切换组件

What is actually happening?

切换报错

function toggleCC(){
    t.value = 2;
+  nextTick(() => {
     Comp.value=CC  // 挂载到Parent 行为 
+  });
}

t.value = 2 卸载Parent dom行为 与 Comp.value=CC 挂载到Parent dom 行为,在同一队列下执行是矛盾的,如报错 Cannot read properties of null (reading 'parentNode')所说

@npmrun
Copy link
Author

npmrun commented Apr 18, 2022

是的,加了nextTick不报错了。如果是去掉transition也不报错

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants