Subscribe on changes!

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

avatar
Apr 7th 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?

切换报错

avatar
Apr 13th 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?

切换报错

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')所说

avatar
Apr 18th 2022

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