tiny-vue/examples/sites/demos/mobile-first/app/carousel/carousel-events.vue

48 lines
1001 B
Vue
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div>
<tiny-carousel height="150px" @change="handleChange">
<tiny-carousel-item :class="bgColor[item - 1]" v-for="item in 4" :key="item">
<h3>{{ item }}</h3>
</tiny-carousel-item>
</tiny-carousel>
<div class="carousel-tip">当前幻灯片索引{{ curValue }}上一张幻灯片索引{{ preValue }}</div>
</div>
</template>
<script>
import { Carousel, CarouselItem } from '@opentiny/vue'
export default {
components: {
TinyCarousel: Carousel,
TinyCarouselItem: CarouselItem
},
data() {
return {
curValue: 0,
preValue: 0,
bgColor: [
'bg-color-info-primary-subtle',
'bg-color-success-subtle',
'bg-color-icon-primary',
'bg-color-warning-subtle'
]
}
},
methods: {
handleChange(value, oldValue) {
this.curValue = value
this.preValue = oldValue
}
}
}
</script>
<style scoped>
.carousel-tip {
margin: 16px 0 0;
text-align: center;
}
</style>