新版swiper显示不出 pagination
来源:2-6 Vue项目首页 - 首页轮播图(2)
_小恐龙
2020-08-25 15:42:41
<template>
<div class="wrapper">
<swiper ref="mySwiper" :options="swiperOptions">
<swiper-slide v-for="item of imgList" :key="item.id">
<img class="swiper-img" :src="item.imgUrl" />
</swiper-slide>
<div class="swiper-pagination" slot="pagination"></div>
</swiper>
</div>
</template>
<script>
export default {
name: 'HomeSwiper',
data () {
return {
swiperOptions: {
pagination: {
el: 'swiper-pagination',
clickable: true,
},
autoplay: true,
loop: true
},
imgList: [
{
id: '001',
imgUrl: 'https://imgs.qunarzz.com/sight/source/1811/15/66f14e0fd6fbb.jpg_r_640x214_5d69f21d.jpg'
},
{
id: '002',
imgUrl: 'https://imgs.qunarzz.com/sight/source/1811/b8/5d599bbdcf8b57.jpg_r_640x214_2ee055e3.jpg'
}
]
}
}
}
</script>
<style lang="stylus">
.swiper-img
width: 100%
</style>
请老师帮忙看一下, 万分感谢!
1回答
同学你好,以4.1.1版本的vue-awesome-swipe为例(同时swiper版本大于6,比如^6.1.2"),需要在main.js中配置如下两句代码:
import Swiper2, {Navigation, Pagination} from 'swiper'
Swiper2.use([Navigation, Pagination])

然后配置pagination时,注意类名前要有点“.swiper-pagination”:

这样设置后,就可以出现小点了。
另外,由于新版本的swiper,很多功能没有详细的文档说明(文档与使用也不符),使用起来非常不方便,因此建议同学将其更换成课程中对应的版本,安装指令:npm i vue-awesome-swiper@2.6.7 --save,该版本更稳定,文档、资料也更多。
如果我的回答帮到了你,欢迎采纳,祝学习愉快!
相似问题