example(tab-bar): add gesture switching

This commit is contained in:
xuxiaoyan 2019-04-25 16:33:10 +08:00
parent 7b6a32f783
commit cc29cd102f
2 changed files with 70 additions and 1 deletions

View File

@ -0,0 +1,68 @@
<template>
<div class="md-example-child md-example-child-tabs md-example-child-tab-bar-6">
<md-tab-bar
v-model="current"
:items="items"
@change="onTabChange"
></md-tab-bar>
<md-swiper
ref="swiper"
:autoplay="0"
:is-prevent="false"
:is-loop="false"
:has-dots="false"
@before-change="onSwiperChange"
>
<md-swiper-item>
她对他很满意走吧他起身买单腿却一拐一拐的难怪他才华横溢事业有成却还是单身趁着他买单她赶紧悄悄走了
</md-swiper-item>
<md-swiper-item>
又是一年她又遇到了他他正牵着孩子的手走的飞快
</md-swiper-item>
</md-swiper>
</div>
</template>
<script> import {TabBar, Swiper, SwiperItem} from 'mand-mobile'
export default {
name: 'tab-bar-demo',
/* DELETE */
title: '手势切换',
titleEnUS: 'Gesture switching',
/* DELETE */
components: {
[TabBar.name]: TabBar,
[Swiper.name]: Swiper,
[SwiperItem.name]: SwiperItem,
},
data() {
return {
current: 0,
items: [{name: 0, label: '标签1'}, {name: 1, label: '标签2'}],
}
},
methods: {
onSwiperChange(from, to) {
this.current = to
},
onTabChange(item, index) {
this.$refs.swiper.goto(index)
},
},
}
</script>
<style>
.md-example-child-tab-bar-6 .md-swiper {
background: #FFF;
}
.md-example-child-tab-bar-6 .md-swiper .md-swiper-item {
padding: 20px;
box-sizing: border-box;
font-size: 24px;
line-height: 1.5;
color: #666;
}
</style>

View File

@ -17,8 +17,9 @@ import Demo2 from './cases/demo2'
import Demo3 from './cases/demo3'
import Demo4 from './cases/demo4'
import Demo5 from './cases/demo5'
import Demo6 from './cases/demo6'
export default {
...createDemoModule('tab-bar', [Demo0, Demo1, Demo2, Demo3, Demo4, Demo5]),
...createDemoModule('tab-bar', [Demo0, Demo1, Demo2, Demo3, Demo4, Demo5, Demo6]),
}
</script>