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的默认显示问题 #2144

Closed
lrdbzs opened this issue Jan 12, 2016 · 7 comments
Closed

slot的默认显示问题 #2144

lrdbzs opened this issue Jan 12, 2016 · 7 comments

Comments

@lrdbzs
Copy link

lrdbzs commented Jan 12, 2016

如果directive定义了

<div>
<slot name="abc">默认显示值</slot>
</div>

使用的时候

<component>
<div slot="abc" v-if="false">替换的内容</div>
</component>

这样的话,“默认显示值”的文字就不出现了。我是希望当v-if="false"的时候显示默认值

@amirrustam
Copy link

@lrdbzs myself and many others would be glad to help you if you could potentially translate these few lines into English. If that's hard, then also know that the community forum has dedicated sections for Chinese and Japanese (sorry I'm not familiar with the characters to differentiate) speaking members:

Otherwise, I hope someone else can assist you.

@tthallos
Copy link

@lrdbzs 取反就好了吧

@xiaolongyuan
Copy link

低级问题不要提 关掉吧

@yyx990803
Copy link
Member

@xiaolongyuan 这个 issue 是个合理问题。当外部插入的内容带有 v-if 的时候不管 v-if 的值是真是假,fallback 内容都不会显示。虽然可能不算 bug 但是是个可以考虑支持的用例。

@AnyGong
Copy link

AnyGong commented Jan 25, 2016

@yyx990803 +1 我今天也需要用到这样的状况,可以加进去吗?

@xiaolongyuan
Copy link

@yyx990803 是的 仔细一看 这个还真是挺蛋疼的
@lrdbzs sorry 没有仔细看, hack 一下

<component>
<div slot="abc" v-if="conditions">替换的内容</div>
<div v-else>默认显示值</div>
</component>

当然 如果使用到到组件作用域那会很蛋疼

@mage3k 认真看下 我开始也大意了

<component>
<div slot="abc" v-if="true">替换的内容</div>
</component>

内容变成了 "替换的内容"

@lrdbzs
Copy link
Author

lrdbzs commented Jan 25, 2016

@xiaolongyuan
没关系,是我用例写得不清晰,让大家误会了。
原来写了个通用的组件,但少数地方使用时,需要替换掉通用组件的一部分。v-if,v-else是我目前的解决办法,只是感觉有点代码臃肿。

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

No branches or pull requests

6 participants