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

slot v-if overwrite #11294

Closed
ShanZiJun opened this issue Jul 4, 2024 · 3 comments
Closed

slot v-if overwrite #11294

ShanZiJun opened this issue Jul 4, 2024 · 3 comments

Comments

@ShanZiJun
Copy link

Vue version

3.1.0

Link to minimal reproduction

https://stackblitz.com/edit/vue-3-composition-api-demo-vaedev?file=src%2FApp.vue,package.json

Steps to reproduce

涉及到slot的时候
外面的slot内容延迟渲染,就会导致无法覆盖slot内部的默认内容
v-if="showOutBtn"

What is expected?

外面的slot内容覆盖slot的默认内容

What is actually happening?

image

System Info

No response

Any additional comments?

No response

@jh-leong
Copy link
Member

jh-leong commented Jul 4, 2024

As a workaround, add a unique key to the slot content:

<button v-if="showOutBtn" @click="triggerOutBtn('showOutBtn')" key="uniqueKey">
  内部slot带if,相同类型元素
</button>

For the complete code, see this playground

The issue occurs because the slot content and fallback content have the same key (the default key for v-if vnode is 0) and vnode type (div), causing patching problems.

a minimal reproduction

@jh-leong
Copy link
Member

jh-leong commented Jul 4, 2024

It looks like this issue will be fixed in #9213

@edison1105
Copy link
Member

Thanks @jh-leong
closing as duplicate of #7256

@edison1105 edison1105 closed this as not planned Won't fix, can't repro, duplicate, stale Jul 5, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jul 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants