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 {