[new feature] Tab: add ellipsis prop (#2299)

This commit is contained in:
neverland
2018-12-15 17:36:13 +08:00
committed by GitHub
parent 5ac7666230
commit fea65f6858
4 changed files with 15 additions and 4 deletions

View File

@@ -24,14 +24,15 @@
class="van-tab"
:class="{
'van-tab--active': index === curActive,
'van-tab--disabled': tab.disabled
'van-tab--disabled': tab.disabled,
'van-tab--complete': !ellipsis
}"
:style="getTabStyle(tab, index)"
@click="onClick(index)"
>
<span
ref="title"
class="van-ellipsis"
:class="{ 'van-ellipsis': ellipsis }"
>
{{ tab.title }}
</span>
@@ -75,6 +76,10 @@ export default create({
animated: Boolean,
offsetTop: Number,
swipeable: Boolean,
ellipsis: {
type: Boolean,
default: true
},
lineWidth: {
type: Number,
default: null
@@ -115,7 +120,7 @@ export default create({
computed: {
// whether the nav is scrollable
scrollable() {
return this.tabs.length > this.swipeThreshold;
return this.tabs.length > this.swipeThreshold || !this.ellipsis;
},
wrapStyle() {
@@ -423,7 +428,7 @@ export default create({
}
}
if (this.scrollable) {
if (this.scrollable && this.ellipsis) {
style.flexBasis = 88 / (this.swipeThreshold) + '%';
}