1用纯css实现轮播
import { swipe, swipeitem } from 'vant'; vue.use(swipe).use(swipeitem);
import vue from 'vue' import vueswiper from 'vue-awesome-swiper' /* 样式的话,我这里有用到分页器,就在全局中引入了样式 */ import 'swiper/dist/css/swiper.css' vue.use(vueswiper);
<swiper :options="swiperoption" class="swiper-wrap" ref="myswiper" v-if="banner.length!=0"> <swiper-slide v-for="(item,index) in banner" :key="index" > <img :src="item.image" alt="" /> </swiper-slide> <!-- 常见的小圆点 --> <div class="swiper-pagination" v-for="(item,index) in banner" :key="index" slot="pagination" ></div> </swiper> <!-- 显示数字 --> <div class="number">{{imgindex}}/{{detailimages.length}}</div>
data() { const that = this; return { imgindex: 1, swiperoption: { //是一个组件自有属性,如果notnexttick设置为true,组件则不会通过nexttick来实例化swiper,也就意味着你可以在第一时间获取到swiper对象,假如你需要刚加载遍使用获取swiper对象来做什么事,那么这个属性一定要是true notnexttick: true, //循环 loop: true, //设定初始化时slide的索引 initialslide: 0, //自动播放 autoplay: { delay: 1500, stoponlastslide: false, /* 触摸滑动后是否继续轮播 */ disableoninteraction: false }, //滑动速度 speed: 800, //滑动方向 direction: "horizontal", //小手掌抓取滑动 grabcursor: true, on: { //滑动之后回调函数 slidechangetransitionstart: function() { /* realindex为滚动到当前的slide索引值 */ that.imgindex= this.realindex - 1; }, }, //分页器设置 pagination: { el: ".swiper-pagination", clickable: true, type: "bullets" } } }; },
如对本文有疑问, 点击进行留言回复!!
深入理解CSS background-blend-mode的作用机制
网友评论