mirror of
https://github.com/youzan/vant.git
synced 2025-10-19 18:14:13 +00:00
swipe add indicator
This commit is contained in:
@@ -6,6 +6,11 @@
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'zan-swipe-item'
|
||||
name: 'zan-swipe-item',
|
||||
|
||||
|
||||
beforeCreate() {
|
||||
this.$parent.swipes.push(this);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@@ -1,6 +1,14 @@
|
||||
<template>
|
||||
<div class="zan-swipe">
|
||||
<slot></slot>
|
||||
<div class="zan-swipe__items">
|
||||
<slot></slot>
|
||||
</div>
|
||||
<div class="zan-swipe__indicators" v-if="showIndicators">
|
||||
<span class="zan-swipe__indicator" v-for="i in swipes.length" :class="{
|
||||
'zan-swipe__indicator--active': currIndex === i -1
|
||||
}">
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -13,13 +21,17 @@ export default {
|
||||
name: 'zan-swipe',
|
||||
|
||||
props: {
|
||||
autoPlay: {
|
||||
autoPlay: Boolean,
|
||||
showIndicators: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
onPageChangeEnd: {
|
||||
type: Function,
|
||||
default: () => {}
|
||||
default: true
|
||||
}
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
currIndex: 0,
|
||||
swipes: []
|
||||
}
|
||||
},
|
||||
|
||||
@@ -53,6 +65,13 @@ export default {
|
||||
|
||||
updated() {
|
||||
this.scroll.update();
|
||||
},
|
||||
|
||||
methods: {
|
||||
onPageChangeEnd(page, currIndex) {
|
||||
this.currIndex = +currIndex;
|
||||
this.$emit('pagechange:end', page, currIndex);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user