computed里面调用vant组件,会触发vue的更新机制错误问题
Version
3.2.11
Reproduction link
Steps to reproduce
点击页面的按钮即可触发
What is expected?
正常弹出toast
What is actually happening?
控制台以及页面报错
分析似乎是computed触发相关依赖更新,但是toast组件部分el是空的,导致报错问题
Open the issue in vant repository first.
Yes, I have been opened.https://github.com/youzan/vant/issues/9487
Then please read and follow https://new-issue.vuejs.org/?repo=vuejs/vue-next#why-repro when reporting a bug. Most bugs should be reproducible with the SFC Playground.
Then please read and follow https://new-issue.vuejs.org/?repo=vuejs/vue-next#why-repro when reporting a bug. Most bugs should be reproducible with the SFC Playground.
Ok, let me check check the vant's sourcecode then reply you.
Sure, make sure it's boiled down. Obviously don't copy paste the code from vant's Toast in the SFC...
@wensc1996 Try like this:
const name = computed(() => {
if (x.value == 0) {
return "张三";
} else {
nextTick(() => {
Toast("你好");
});
return "李四";
}
});
@wensc1996 Try like this:
const name = computed(() => { if (x.value == 0) { return "张三"; } else { nextTick(() => { Toast("你好"); }); return "李四"; } });
thanks, maybe the vue-createVnode conficts with computed update
@posva :sweat_smile: I simplified test case, But not sure if it's a bug. sfc.vuejs.org
Calling the createApp inside of a computed()
seems really weird. It should run outside