[new feature] Tab: add scroll event (#1730)

This commit is contained in:
fenghou 2018-08-31 10:02:37 +08:00 committed by neverland
parent d293047164
commit d32f9a42f3
4 changed files with 14 additions and 1 deletions

View File

@ -9,7 +9,7 @@
</demo-block> </demo-block>
<demo-block :title="$t('title2')"> <demo-block :title="$t('title2')">
<van-tabs> <van-tabs sticky @scroll="subscribeSticky">
<van-tab v-for="index in 8" :title="$t('tab') + index" :key="index"> <van-tab v-for="index in 8" :title="$t('tab') + index" :key="index">
{{ $t('content') }} {{ index }} {{ $t('content') }} {{ index }}
</van-tab> </van-tab>
@ -111,6 +111,10 @@ export default {
onClick(index, title) { onClick(index, title) {
this.$toast(title); this.$toast(title);
},
subscribeSticky(e) {
console.log(e);
} }
} }
}; };
@ -137,9 +141,11 @@ export default {
.custom-tabwrap .van-tab-active { .custom-tabwrap .van-tab-active {
color: #20a0ff; color: #20a0ff;
} }
.custom-tabwrap .van-tabs-nav-bar { .custom-tabwrap .van-tabs-nav-bar {
background: #20a0ff; background: #20a0ff;
} }
.custom-pane { .custom-pane {
text-align: center; text-align: center;
height: 50px; height: 50px;

View File

@ -169,3 +169,4 @@ In swipeable mode, you can switch tabs with swipe gestrue in the content
| click | Triggered when click tab | indexindex of current tabtitle: tab title | | click | Triggered when click tab | indexindex of current tabtitle: tab title |
| change | Triggered when active tab changed | indexindex of current tabtitle: tab title | | change | Triggered when active tab changed | indexindex of current tabtitle: tab title |
| disabled | Triggered when click disabled tab | indexindex of current tab, title: tab title | | disabled | Triggered when click disabled tab | indexindex of current tab, title: tab title |
| scroll | Triggered when tab scroll | escroll arguments |

View File

@ -171,3 +171,4 @@ export default {
| click | 点击标签时触发 | index标签索引title标题 | | click | 点击标签时触发 | index标签索引title标题 |
| change | 当前激活的标签改变时触发 | index标签索引title标题 | | change | 当前激活的标签改变时触发 | index标签索引title标题 |
| disabled | 点击被禁用的标签时触发 | index标签索引title标题 | | disabled | 点击被禁用的标签时触发 | index标签索引title标题 |
| scroll | 滚动时触发 | e滚动参数 |

View File

@ -231,6 +231,11 @@ export default create({
} else { } else {
this.position = ''; this.position = '';
} }
const scrollParams = {
scrollTop,
isFixed: this.position === 'top'
};
this.$emit('scroll', scrollParams);
}, },
// update nav bar style // update nav bar style