this.$refs.swiper.swiper.slideTo(2, 500, false);
<template>
<div>
<swiper ref="swiper"
:options="swiperOption"
style="height:100px">
<swiper-slide v-for='(item,index) in newObjData'
:key="index">
<li v-for='(item,index) in newObjData[index]'
:key="index">
<span>{{item.id}}</span>
<span>{{item.name}}</span>
<span>{{item.age}}</span>
</li>
</swiper-slide>
</swiper>
<button @click="switchPage">切换页码</button>
</div>
</template>
switchPage () {
this.$refs.swiper.swiper.slideTo(2, 500, false);
},
这篇博客展示了如何在Vue应用中利用Swiper组件进行页面切换。通过`swiperOption`配置滑动效果,并在`switchPage`方法中调用`slideTo`函数,实现了在500毫秒内平滑跳转到第3个幻灯片。同时,内容中包含了一个使用`v-for`指令遍历数据并展示的示例。
1226

被折叠的 条评论
为什么被折叠?



