#vue-awesome-swiper轮播图实践
1、安装swiper
1
| npm install swiper@3.4.1 --save
|
2、引用组件
1 2
| import Swiper from 'swiper'; import 'swiper/dist/css/swiper.min.css';
|
3、.vue 文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| <template> <div class="wrapper"> <swiper :options="swiperOption" ref="mySwiper" > <swiper-slide v-for="item of sweiperList" :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: 'carrousel', data() { return { swiperOption: { pagination: '.swiper-pagination', loop: true }, sweiperList:[{ id:'001', imgUrl:'http://img1.qunarzz.com/piao/fusion/1804/22/0e335ab3af3e3f02.jpg_750x200_cf284e05.jpg' },{ id:'002', imgUrl:'http://img1.qunarzz.com/piao/fusion/1806/a1/e645466a5a1c9a02.jpg_750x200_9c489fbd.jpg' }] } } } </script> <style lang="stylus" scoped> .wrapper width 100% height 0 overflow hidden padding-bottom 31.25% .swiper-img width 100%
</style>
|