我是靠谱客的博主 虚心黑猫,这篇文章主要介绍vue2.0使用swiper实现轮播广告,现在分享给大家,希望可以做个参考。

这次给大家带来vue2.0使用swiper实现轮播广告,vue2.0使用swiper实现轮播广告的注意事项有哪些,下面就是实战案例,一起来看一下。

1、安装swiper

复制代码
1
npm install swiper@3.4.1 --save-dev
登录后复制

2、引用组件

复制代码
1
2
import Swiper from 'swiper'; import 'swiper/dist/css/swiper.min.css';
登录后复制

3、html页面代码

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
<p class="swiper-container" id="swiper"> <p class="swiper-wrapper"> <p class="swiper-slide" v-for="(item,$index) in detail.imgs"> <a v-on:click="showPreview($index,detail.imgs,swiperObj)"> <figure class="wp-avatar banner"> <img v-cloak :src="item | toQiNiuImg"/> </figure> </a> </p> </p> <!-- Add Pagination --> <p class="swiper-pagination"></p> </p>
登录后复制

4、初始化组件,并设置参数

复制代码
1
2
3
4
5
6
7
8
setTimeout(function () { state.swiperObj = new Swiper('#swiper', { loop: true, pagination: '.swiper-pagination', autoplay: 2000, paginationClickable: true }); }, 100)
登录后复制

5、搞定,ok

相信看了本文案例你已经掌握了方法,更多精彩请关注靠谱客其它相关文章!

推荐阅读:

web端的应用实现后退强制刷新

Vue.directive()的图文详解

以上就是vue2.0使用swiper实现轮播广告的详细内容,更多请关注靠谱客其它相关文章!

最后

以上就是虚心黑猫最近收集整理的关于vue2.0使用swiper实现轮播广告的全部内容,更多相关vue2内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(107)

评论列表共有 0 条评论

立即
投稿
返回
顶部