[new feature]: tabs component add swipeThreshold prop (#206)

This commit is contained in:
张敏
2017-10-12 22:52:13 -05:00
committed by GitHub
parent f019b75b04
commit f9fa2fc1c3
2 changed files with 11 additions and 7 deletions

View File

@@ -1,6 +1,6 @@
<template>
<div class="van-tabs" :class="[`van-tabs--${type}`]">
<div class="van-tabs__nav-wrap" v-if="type === 'line' && tabs.length > 4">
<div class="van-tabs__nav-wrap" v-if="type === 'line' && tabs.length > swipeThreshold">
<div class="van-tabs__swipe" ref="swipe">
<div class="van-tabs__nav van-tabs__nav--line">
<div class="van-tabs__nav-bar" :style="navBarStyle"></div>
@@ -62,6 +62,10 @@
duration: {
type: Number,
default: 0.3
},
swipeThreshold: {
type: Number,
default: 4
}
},
@@ -81,7 +85,7 @@
curActive() {
/* istanbul ignore else */
if (this.tabs.length > 4) {
if (this.tabs.length > this.swipeThreshold) {
this.doOnValueChange();
}
}
@@ -127,7 +131,7 @@
this.isReady = true;
this.initEvents();
if (this.tabs.length > 4) {
if (this.tabs.length > this.swipeThreshold) {
this.doOnValueChange();
}
});