chore(Tab): optimize implementation of title slot (#4974)
This commit is contained in:
+1
-11
@@ -41,20 +41,10 @@ export default createComponent({
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
if (this.slots('title')) {
|
||||
this.parent.renderTitle(this.$refs.title, this.index);
|
||||
}
|
||||
},
|
||||
|
||||
render(h) {
|
||||
const { slots, isActive } = this;
|
||||
const shouldRender = this.inited || !this.parent.lazyRender;
|
||||
const Content = [shouldRender ? slots() : h()];
|
||||
|
||||
if (slots('title')) {
|
||||
Content.push(<div ref="title">{slots('title')}</div>);
|
||||
}
|
||||
const Content = shouldRender ? slots() : h();
|
||||
|
||||
if (this.parent.animated) {
|
||||
return (
|
||||
|
||||
@@ -194,10 +194,10 @@ exports[`renders demo correctly 1`] = `
|
||||
<div class="van-tabs van-tabs--line">
|
||||
<div class="van-tabs__wrap van-hairline--top-bottom">
|
||||
<div role="tablist" class="van-tabs__nav van-tabs__nav--line">
|
||||
<div role="tab" aria-selected="true" class="van-tab van-tab--active"><span class="van-ellipsis"><div><i class="van-icon van-icon-more-o"><!----></i>标签
|
||||
</div></span></div>
|
||||
<div role="tab" class="van-tab"><span class="van-ellipsis"><div><i class="van-icon van-icon-more-o"><!----></i>标签
|
||||
</div></span></div>
|
||||
<div role="tab" aria-selected="true" class="van-tab van-tab--active"><span class="van-ellipsis"><i class="van-icon van-icon-more-o"><!----></i>标签
|
||||
</span></div>
|
||||
<div role="tab" class="van-tab"><span class="van-ellipsis"><i class="van-icon van-icon-more-o"><!----></i>标签
|
||||
</span></div>
|
||||
<div class="van-tabs__line" style="width: 0px; transform: translateX(0px) translateX(-50%);"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user