diff --git a/src/coupon-list/test/__snapshots__/index.spec.js.snap b/src/coupon-list/test/__snapshots__/index.spec.js.snap index 29171bccc..915cc62fd 100644 --- a/src/coupon-list/test/__snapshots__/index.spec.js.snap +++ b/src/coupon-list/test/__snapshots__/index.spec.js.snap @@ -12,8 +12,8 @@ exports[`empty-image prop 1`] = `
- - + +
@@ -62,8 +62,8 @@ exports[`render coupon list 1`] = `
- - + +
@@ -208,8 +208,8 @@ exports[`render empty coupon list 1`] = `
- - + +
diff --git a/src/empty/test/__snapshots__/demo.spec.js.snap b/src/empty/test/__snapshots__/demo.spec.js.snap index 3771c5aba..fb3d618ca 100644 --- a/src/empty/test/__snapshots__/demo.spec.js.snap +++ b/src/empty/test/__snapshots__/demo.spec.js.snap @@ -12,9 +12,9 @@ exports[`renders demo correctly 1`] = `
- - - + + +
diff --git a/src/index-bar/test/__snapshots__/demo.spec.js.snap b/src/index-bar/test/__snapshots__/demo.spec.js.snap index 8e8a6208f..cf8eb2823 100644 --- a/src/index-bar/test/__snapshots__/demo.spec.js.snap +++ b/src/index-bar/test/__snapshots__/demo.spec.js.snap @@ -5,8 +5,8 @@ exports[`renders demo correctly 1`] = `
- - + +
diff --git a/src/list/test/__snapshots__/demo.spec.js.snap b/src/list/test/__snapshots__/demo.spec.js.snap index 6faa69720..6d37e2079 100644 --- a/src/list/test/__snapshots__/demo.spec.js.snap +++ b/src/list/test/__snapshots__/demo.spec.js.snap @@ -5,9 +5,9 @@ exports[`renders demo correctly 1`] = `
- - - + + +
diff --git a/src/pull-refresh/test/__snapshots__/demo.spec.js.snap b/src/pull-refresh/test/__snapshots__/demo.spec.js.snap index 26df811a6..50db4583c 100644 --- a/src/pull-refresh/test/__snapshots__/demo.spec.js.snap +++ b/src/pull-refresh/test/__snapshots__/demo.spec.js.snap @@ -5,9 +5,9 @@ exports[`renders demo correctly 1`] = `
- - - + + +
diff --git a/src/tab/test/__snapshots__/demo.spec.js.snap b/src/tab/test/__snapshots__/demo.spec.js.snap index 742bde7c8..e8b7e703a 100644 --- a/src/tab/test/__snapshots__/demo.spec.js.snap +++ b/src/tab/test/__snapshots__/demo.spec.js.snap @@ -6,10 +6,10 @@ exports[`renders demo correctly 1`] = `
- - - - + + + +
@@ -33,9 +33,9 @@ exports[`renders demo correctly 1`] = `
- - - + + +
@@ -54,14 +54,14 @@ exports[`renders demo correctly 1`] = `
- - - - - - - - + + + + + + + +
@@ -97,9 +97,9 @@ exports[`renders demo correctly 1`] = `
- - - + + +
@@ -120,9 +120,9 @@ exports[`renders demo correctly 1`] = `
- - - + + +
@@ -142,8 +142,8 @@ exports[`renders demo correctly 1`] = `
- - + +
@@ -163,10 +163,10 @@ exports[`renders demo correctly 1`] = `
- - - - + + + +
@@ -192,8 +192,8 @@ exports[`renders demo correctly 1`] = `
- - + +
@@ -211,10 +211,10 @@ exports[`renders demo correctly 1`] = `
- - - - + + + +
@@ -248,10 +248,10 @@ exports[`renders demo correctly 1`] = `
- - - - + + + +
@@ -277,14 +277,14 @@ exports[`renders demo correctly 1`] = `
- - - - - - - - + + + + + + + +
diff --git a/src/tab/test/__snapshots__/index.spec.js.snap b/src/tab/test/__snapshots__/index.spec.js.snap index 8f9fbc505..6f4a6c641 100644 --- a/src/tab/test/__snapshots__/index.spec.js.snap +++ b/src/tab/test/__snapshots__/index.spec.js.snap @@ -17,9 +17,9 @@ exports[`change tabs data 1`] = `
- - - + + +
@@ -41,9 +41,9 @@ exports[`change tabs data 2`] = `
- - - + + +
@@ -62,9 +62,9 @@ exports[`click to switch tab 1`] = `
- - - + + +
@@ -84,9 +84,9 @@ exports[`click to switch tab 2`] = `
- - - + + +
@@ -104,7 +104,9 @@ exports[`dot prop 1`] = `
- +
@@ -118,7 +120,9 @@ exports[`info prop 1`] = `
- +
@@ -134,9 +138,9 @@ exports[`lazy render 1`] = `
- - - + + +
@@ -160,9 +164,9 @@ exports[`lazy render 2`] = `
- - - + + +
@@ -180,9 +184,9 @@ exports[`name prop 1`] = `
- - - + + +
@@ -203,9 +207,9 @@ exports[`render nav-left & nav-right slot 1`] = `
-
Nav Left - - +
Nav Left + +
Nav Right
@@ -231,9 +235,9 @@ exports[`scrollspy 1`] = `
- - - + + +
@@ -253,9 +257,9 @@ exports[`scrollspy 2`] = `
- - - + + +
@@ -273,9 +277,9 @@ exports[`swipe to switch tab 1`] = `
- - - + + +
@@ -295,9 +299,9 @@ exports[`swipe to switch tab 2`] = `
- - - + + +
@@ -315,9 +319,9 @@ exports[`swipe to switch tab 3`] = `
- - - + + +
diff --git a/src/tab/test/__snapshots__/insert.spec.js.snap b/src/tab/test/__snapshots__/insert.spec.js.snap index b94a0a83a..ce51d5a48 100644 --- a/src/tab/test/__snapshots__/insert.spec.js.snap +++ b/src/tab/test/__snapshots__/insert.spec.js.snap @@ -4,9 +4,9 @@ exports[`insert tab dynamically 1`] = `
- - - + + +
@@ -26,9 +26,9 @@ exports[`insert tab with child component 1`] = `
- - - + + +
diff --git a/src/tabs/Title.js b/src/tabs/Title.js index aa55aba1d..0f3e481fc 100644 --- a/src/tabs/Title.js +++ b/src/tabs/Title.js @@ -1,4 +1,4 @@ -import { createNamespace } from '../utils'; +import { createNamespace, isDef } from '../utils'; import Info from '../info'; const [createComponent, bem] = createNamespace('tab'); @@ -55,6 +55,25 @@ export default createComponent({ onClick() { this.$emit('click'); }, + + genText() { + const Text = ( + + {this.slots() || this.title} + + ); + + if (this.dot || (isDef(this.info) && this.info !== '')) { + return ( + + {Text} + {} + + ); + } + + return Text; + }, }, render() { @@ -68,17 +87,11 @@ export default createComponent({ disabled: this.disabled, complete: !this.ellipsis, }), - { - 'van-ellipsis': this.ellipsis, - }, ]} style={this.style} onClick={this.onClick} > - - {this.slots() || this.title} - - + {this.genText()}
); }, diff --git a/src/tabs/index.less b/src/tabs/index.less index d4d645dc5..e3e2912da 100644 --- a/src/tabs/index.less +++ b/src/tabs/index.less @@ -2,14 +2,14 @@ .van-tab { position: relative; + display: flex; + align-items: center; + justify-content: center; flex: 1; box-sizing: border-box; - min-width: 0; // hack for flex ellipsis - padding: 0 5px; + padding: 0 @padding-base; color: @tab-text-color; font-size: @tab-font-size; - line-height: @tabs-line-height; - text-align: center; cursor: pointer; &--active { @@ -23,6 +23,15 @@ } &__text { + &--ellipsis { + display: -webkit-box; + -webkit-line-clamp: 1; + -webkit-box-orient: vertical; + overflow: hidden; + } + } + + &__text-wrapper { position: relative; } } @@ -52,8 +61,8 @@ } .van-tabs__nav { - overflow: hidden; overflow-x: auto; + overflow-y: hidden; -webkit-overflow-scrolling: touch; &::-webkit-scrollbar { @@ -84,7 +93,6 @@ .van-tab { color: @tabs-default-color; - line-height: @tabs-card-height - 2px; border-right: @border-width-base solid @tabs-default-color; &:last-child {