首页 技术 正文
技术 2022年11月15日
0 收藏 805 点赞 2,299 浏览 1345 个字

最近自己在做一个基于vue的知乎的移动端单页面,遇到很多坑,先说一下遇到最大的坑,其实并不推荐使用 vue-awesome-swiper,如果项目应用轮播,切换少的话。言归正传,现在来介绍vue-awesome-swiper的使用方法。

首先基于的是vue2.0。

1, 使用npm安装

npm install vue-awesome-swiper --save

2,引入资源(本身vue-awesome-swiper就很大了,这里推荐全局引入)

在main.js内

import VueAwesomeSWiper  from 'vue-awesome-swiper'// 引入插件
import 'swiper/dist/css/swiper.css' //引入轮播样式,必须要引入,我就上了这个的亏Vue.use(VueAwesomeSWiper)

样式的路径是基于node-module的

vue-awesome-swiper插件爬坑

3,在所在的组件中使用:

模板文件

<template>
<div>
<swiper :options="swiperOption" ref="mySwiper">
<!-- slides -->
<swiper-slide v-for="top in tops">
<img :src="top.image">
<div></div>
<h3>{{top.title}}</h3>
</swiper-slide>
<!-- Optional controls -->
<div class="swiper-pagination" slot="pagination"></div>
</swiper>
</div>
</template>

js

export default {
data() {
return {
swiperOption:{
autoplay: {
delay:3000
},
direction: 'horizontal',
effect: 'slide',
loop: false,
pagination:{
el:'.swiper-pagination',
type: 'bullets'
},
autoplayDisableOnInteraction: false,
observer: true,
observeParents: true
}
},
computed: {
swiper() {
return this.$refs.mySwiper.swiper
}
},
}

常用的属性配置:

Autoplay  // 自动切换时间间隔 单位ms

设置为true启动自动切换,可以设置下面的delay属性,设置切换时间

pagination(分页器)

el: 分页的元素

type: 分页的形式

“bullets” 圆点

“fraction” 分式

“progressbar” 进度条

“custom”  自定义

effects 切换效果

effect : ‘slide'(唯一切换)  可设置为 slide(普通切换),fade(淡入), cube(方块)coverflow”(3d流)”flip”(3d翻转)。

loop

设置为true 则开启loop模式。loop模式:会在原本slide前后复制若干个slide(默认一个)并在合适的时候切换,让Swiper看起来是循环的。 
loop模式在与free模式同用时会产生抖动,因为free模式下没有复制slide的时间点。

后续再补,新入坑好多东西不懂

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,964
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,486
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,331
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,114
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,747
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,781