tiny-vue/examples/sites/demos/pc/app/carousel/carousel-events-composition...

39 lines
892 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="carousel-item-demo" 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 setup>
import { ref } from 'vue'
import { Carousel as TinyCarousel, CarouselItem as TinyCarouselItem } from '@opentiny/vue'
const curValue = ref(0)
const preValue = ref(0)
function handleChange(value, oldValue) {
curValue.value = value
preValue.value = oldValue
}
</script>
<style scoped>
.carousel-item-demo:nth-child(2n) {
background-color: #fafafa;
}
.carousel-item-demo:nth-child(2n + 1) {
background-color: #edf0f3;
}
.carousel-tip {
margin: 16px 0 0;
text-align: center;
}
</style>