mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[new feature] Tab: add ellipsis prop (#2299)
This commit is contained in:
parent
5ac7666230
commit
fea65f6858
@ -160,6 +160,7 @@ In swipeable mode, you can switch tabs with swipe gestrue in the content
|
|||||||
| offset-top | Offset top when use sticky mode | `Number` | `0` |
|
| offset-top | Offset top when use sticky mode | `Number` | `0` |
|
||||||
| swipeable | Whether to switch tabs with swipe gestrue in the content | `Boolean` | `false` |
|
| swipeable | Whether to switch tabs with swipe gestrue in the content | `Boolean` | `false` |
|
||||||
| animated | Whether to change tabs with animation | `Boolean` | `false` |
|
| animated | Whether to change tabs with animation | `Boolean` | `false` |
|
||||||
|
| ellipsis | Whether to ellipsis too long title | `Boolean` | `true` |
|
||||||
|
|
||||||
### Tab API
|
### Tab API
|
||||||
|
|
||||||
|
@ -164,6 +164,7 @@ export default {
|
|||||||
| offset-top | 粘性定位布局下与顶部的最小距离,单位 px | `Number` | `0` | 1.1.15 |
|
| offset-top | 粘性定位布局下与顶部的最小距离,单位 px | `Number` | `0` | 1.1.15 |
|
||||||
| swipe-threshold | 滚动阈值,标签数量超过多少个可滚动 | `Number` | `4` | - |
|
| swipe-threshold | 滚动阈值,标签数量超过多少个可滚动 | `Number` | `4` | - |
|
||||||
| animated | 是否开启切换标签内容时的转场动画 | `Boolean` | `false` | 1.4.5 |
|
| animated | 是否开启切换标签内容时的转场动画 | `Boolean` | `false` | 1.4.5 |
|
||||||
|
| ellipsis | 是否省略过长的标题文字 | `Boolean` | `true` | 1.5.0 |
|
||||||
|
|
||||||
### Tab API
|
### Tab API
|
||||||
|
|
||||||
|
@ -50,6 +50,10 @@
|
|||||||
&--scrollable {
|
&--scrollable {
|
||||||
.van-tab {
|
.van-tab {
|
||||||
flex: 0 0 22%;
|
flex: 0 0 22%;
|
||||||
|
|
||||||
|
&--complete {
|
||||||
|
flex: 1 0 auto;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.van-tabs__nav {
|
.van-tabs__nav {
|
||||||
|
@ -24,14 +24,15 @@
|
|||||||
class="van-tab"
|
class="van-tab"
|
||||||
:class="{
|
:class="{
|
||||||
'van-tab--active': index === curActive,
|
'van-tab--active': index === curActive,
|
||||||
'van-tab--disabled': tab.disabled
|
'van-tab--disabled': tab.disabled,
|
||||||
|
'van-tab--complete': !ellipsis
|
||||||
}"
|
}"
|
||||||
:style="getTabStyle(tab, index)"
|
:style="getTabStyle(tab, index)"
|
||||||
@click="onClick(index)"
|
@click="onClick(index)"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
ref="title"
|
ref="title"
|
||||||
class="van-ellipsis"
|
:class="{ 'van-ellipsis': ellipsis }"
|
||||||
>
|
>
|
||||||
{{ tab.title }}
|
{{ tab.title }}
|
||||||
</span>
|
</span>
|
||||||
@ -75,6 +76,10 @@ export default create({
|
|||||||
animated: Boolean,
|
animated: Boolean,
|
||||||
offsetTop: Number,
|
offsetTop: Number,
|
||||||
swipeable: Boolean,
|
swipeable: Boolean,
|
||||||
|
ellipsis: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
lineWidth: {
|
lineWidth: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: null
|
default: null
|
||||||
@ -115,7 +120,7 @@ export default create({
|
|||||||
computed: {
|
computed: {
|
||||||
// whether the nav is scrollable
|
// whether the nav is scrollable
|
||||||
scrollable() {
|
scrollable() {
|
||||||
return this.tabs.length > this.swipeThreshold;
|
return this.tabs.length > this.swipeThreshold || !this.ellipsis;
|
||||||
},
|
},
|
||||||
|
|
||||||
wrapStyle() {
|
wrapStyle() {
|
||||||
@ -423,7 +428,7 @@ export default create({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.scrollable) {
|
if (this.scrollable && this.ellipsis) {
|
||||||
style.flexBasis = 88 / (this.swipeThreshold) + '%';
|
style.flexBasis = 88 / (this.swipeThreshold) + '%';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user