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

vue slot 里面插入slot上面的默认内容显示不出来,而且我在我的项目里还会出现undefined #12153

Closed
wuli-collov opened this issue Jun 28, 2021 · 11 comments

Comments

@wuli-collov
Copy link

Version

2.6.14

Reproduction link

https://codesandbox.io/s/amazing-easley-n35zm?file=/src/components/HelloWorld.vue

Steps to reproduce

组件里面写两个slot

插槽默认内容

hello

父页面调用组件

123

就显示不出来插槽默认内容

What is expected?

不要出现这个bug

What is actually happening?

出现了slot bug

@posva
Copy link
Member

posva commented Jun 28, 2021

It's

<HelloWorld msg="Hello Vue in CodeSandbox!">
      <template #hello>123</template>
    </HelloWorld>

or v-slot:hello


Please, next time consider using the forum, the Discord server or StackOverflow for questions first. But feel free to come back and open an issue if it turns out to be a bug 🙂

@posva posva closed this as completed Jun 28, 2021
@wuli-collov
Copy link
Author

It's

<HelloWorld msg="Hello Vue in CodeSandbox!">
      <template #hello>123</template>
    </HelloWorld>

or v-slot:hello

Please, next time consider using the forum, the Discord server or StackOverflow for questions first. But feel free to come back and open an issue if it turns out to be a bug 🙂

额。。。那这个和旧的就不兼容了啊

@yangmiao7
Copy link

If slot fallback content is Vue component, fallback content is not work,

@wuli-collov
Copy link
Author

If slot fallback content is Vue component, fallback content is not work,

yes,Can this problem be solved

@BryanAdamss
Copy link

fallback to 2.6.12 its work for me

@wsida
Copy link

wsida commented Aug 5, 2021

要注意 vue 与 vue-template-compiler 版本一致,主要原因是 vue 中 renderSlot 方法 调整,在 v2.6.13 版本,renderSlot 第二个参数支持 函数类型,同时 vue-template-compiler 编译slot 返回一个函数,但是v2.6.12 版本,renderSlot 第二个参数只是VNode,同时 vue-template-compiler 编译slot 直接返回一个VNode。因此如果 vue-template-compiler 版本比vue 版本高,就会出现这种情况。希望有帮助

@shimangdian
Copy link

fallback to 2.6.12 its work for me too,thanks for @BryanAdamss

@tnnevol
Copy link

tnnevol commented Oct 27, 2021

我目前也是这样,slot的后备内容没法正常渲染,vue 2.6.12 vue-template-compiler 2.6.12,版本一致呀,请问要更新到哪个版本还是回退到哪个版本,我都快吐了,不想看源码了。

@BryanAdamss
Copy link

我目前也是这样,slot的后备内容没法正常渲染,vue 2.6.12 vue-template-compiler 2.6.12,版本一致呀,请问要更新到哪个版本还是回退到哪个版本,我都快吐了,不想看源码了。

检查下node_modules和lock文件,看下最终安装的版本是否都是2.6.12

@tnnevol
Copy link

tnnevol commented Oct 27, 2021

我目前也是这样,slot的后备内容没法正常渲染,vue 2.6.12 vue-template-compiler 2.6.12,版本一致呀,请问要更新到哪个版本还是回退到哪个版本,我都快吐了,不想看源码了。

检查下node_modules和lock文件,看下最终安装的版本是否都是2.6.12

ok啦,package里面的版本做了向上导致node_modules一直下的最新包

@qingniao99
Copy link

get it! thanks all.

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

No branches or pull requests

8 participants