Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

[Bug Report] 动态切换插槽更新问题 #11374

Closed
haiweilian opened this issue Dec 10, 2022 · 5 comments
Closed

[Bug Report] 动态切换插槽更新问题 #11374

haiweilian opened this issue Dec 10, 2022 · 5 comments
Labels

Comments

@haiweilian
Copy link
Contributor

重现链接

https://codesandbox.io/s/vant-3-issue-template-forked-mzx0b6?file=/src/App.vue

Vant 版本

4.0.2

描述一下你遇到的问题。

此问题引用 #11368 因为涉及多个组件所以重新开一个。

个别组件使用动态切换插槽不更新。此问题是 vue 插槽更新策略的问题 https://github.com/vuejs/core/blob/main/packages/runtime-core/src/componentSlots.ts#L207
如果值是 null / undefinedin 检测也会存在所以不会删除。有更改此行为的 pr 但没有任何回复。

所以这个不是这单个组件的问题,当然要在特定的用例下才会复现所以这并不常见,我复现了一个 https://codesandbox.io/s/vant-3-issue-template-forked-mzx0b6?file=/src/App.vue 用例。

所以要解决此类问题需要在使用 v-slots={{ a: () => <Cell>, b: null, c: undefined }} 命名接收插槽地方去排除 null / undefined 即可修复。我看到你已经通过判断内容修复了此问题,是否考虑应从根源解决和全部修复。

重现步骤

使用 v-if 切换插槽。

设备/浏览器

No response

@chenjiahan
Copy link
Member

目前确实只处理了单个 case,我理解根源解决还是需要 Vue 框架内部来做变更,能贴一下相关 PR 的链接不

@haiweilian
Copy link
Contributor Author

haiweilian commented Dec 11, 2022

目前确实只处理了单个 case,我理解根源解决还是需要 Vue 框架内部来做变更,能贴一下相关 PR 的链接不

vuejs/core#6484 不太认为会更改此行为。

@chenjiahan
Copy link
Member

为啥不太认为会更改此行为呢,我看这个 PR 的改动是合理的,提 PR 的开发者是 Vuetify Team 成员,估计 Vuetify 也遇到了类似的问题。

@haiweilian
Copy link
Contributor Author

为啥不太认为会更改此行为呢,我看这个 PR 的改动是合理的,提 PR 的开发者是 Vuetify Team 成员,估计 Vuetify 也遇到了类似的问题。

改动是合理的,你可以跟进下这个问题吗,不知道为什么这么久了没有回复。

@chenjiahan
Copy link
Member

我看 PR 里有回复了,可以继续观察下~

@youzan youzan locked and limited conversation to collaborators Apr 2, 2023
@chenjiahan chenjiahan converted this issue into discussion #11727 Apr 2, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Projects
None yet
Development

No branches or pull requests

2 participants