vue-awesome-swiper是基于swiper的一个轮播图插件,使用非常方便。

首先安装下

 npm install vue-awesome-swiper --save

然后在入口文件main.js引入下

import VueAwesomeSwiper from 'vue-awesome-swiper'
import './static/css/swiper.min.css'
Vue.use(VueAwesomeSwiper)

最后运用到组件中

<template>
<div class="scroll">
<swiper :options="swiperOption" ref="mySwiper">
<!-- slides -->
<swiper-slide>I'm Slide 1</swiper-slide>
<swiper-slide>I'm Slide 2</swiper-slide>
<swiper-slide>I'm Slide 3</swiper-slide>
<swiper-slide>I'm Slide 4</swiper-slide>
<!-- Optional controls -->
<div class="swiper-pagination " slot="pagination"></div>
<div class="swiper-button-prev swiper-button-black" slot="button-prev"></div>
<div class="swiper-button-next swiper-button-black" slot="button-next"></div>
<!-- <div class="swiper-scrollbar" slot="scrollbar"></div> -->
</swiper>
</div>
</template> <script>
import { swiper, swiperSlide } from 'vue-awesome-swiper'
export default {
name: 'HelloWorld',
components: {
swiper,
swiperSlide
},
data () {
return {
swiperOption: {
notNextTick: true,
//循环
loop:true,
//设定初始化时slide的索引
initialSlide:0,
//自动播放
autoplay:true,
// autoplay: {
// delay: 3000,
// stopOnLastSlide: false,
// disableOnInteraction: true,
// },
// 设置轮播
effect : 'flip',
//滑动速度
speed:800,
//滑动方向
direction : 'horizontal',
//小手掌抓取滑动
// grabCursor : true,
//滑动之后回调函数
on: {
slideChangeTransitionEnd: function(){
// console.log(this.activeIndex);//切换结束时,告诉我现在是第几个slide
},
},
//左右点击
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
//分页器设置
pagination: {
el: '.swiper-pagination',
clickable :true
}
},
swiperSlides: [1, 2, 3, 4]
}
},
computed: {
swiper() {
return this.$refs.mySwiper.swiper;
}
},
mounted () {
//可以使用swiper这个对象去使用swiper官网中的那些方法
console.log('this is current swiper instance object', this.swiper);
// this.swiper.slideTo(0, 0, false);
}
}
</script>

容易出现的问题

1、vue-awesome-swiper组件pagination小圆点没有显示

2、组件没有自动播放

参考文档:https://segmentfault.com/a/1190000013995395

vue使用vue-awesome-swiper及一些问题的更多相关文章

  1. 在Vue中使用了Swiper ,动态从后台获取数据的之后,swiper滑动失效??

    在Vue中使用了Swiper ,动态从后台获取数据的之后,swiper滑动失效?? 是因为swiper提前初始化了,那时候数据还没有完全出来.这里有两种解决办法 1. 使用vue提供的$nextTic ...

  2. vue入门 vue与react和Angular的关系和区别

    一.为什么学习vue.js vue.js兼具angular.js和react的优点,并且剔除了他们的缺点 官网:http://cn.vuejs.org/ 手册:http://cn.vuejs.org/ ...

  3. Vue (三) --- Vue 组件开发

    ------------------------------------------------------------------好心情,会让你峰回路转. 5. 组件化开发 5.1 组件[compo ...

  4. vue学习:vue+webpack的快速使用指南(新手向)

    一.vue有两种使用方式: 1.下载vue.js <script src="vue.js"></script> 2.使用npm npm install vu ...

  5. Vue 项目 Vue + restfulframework

    Vue 项目 Vue + restfulframework 实现登录认证 - django views class MyResponse(): def __init__(self): self.sta ...

  6. 【vue】vue +element 搭建项目,组件之间通信

    父子组件通信 父 通过props属性给 子传递数据 子 操作 父  this.$parent.XXX 子通过$emit传递参数 或者通过vue-bus vue-bus既可以实现父子组件之间的通信,也可 ...

  7. 【vue】vue +element 搭建项目,vuex中的store使用

    概述: 每一个 Vuex 应用的核心就是 store(仓库).“store”基本上就是一个容器,它包含着你的应用中大部分的状态 (state).Vuex 和单纯的全局对象有以下两点不同: Vuex 的 ...

  8. vue的.vue文件是怎么run起来的(vue-loader)

    vue的.vue文件是怎么run起来的(vue-loader) 引子:vue的.vue文件是怎么跑起来的? 答:通过vue-loader,解析.vue文件,在webpack解析,拆解vue组件 1.v ...

  9. vue学习之用 Vue.js + Vue Router 创建单页应用的几个步骤

    通过vue学习一:新建或打开vue项目,创建好项目后,接下来的操作为: src目录重新规划——>新建几个页面——>配置这几个页面的路由——>给根实例注入路由配置 src目录重整 在项 ...

  10. python 全栈开发,Day89(sorted面试题,Pycharm配置支持vue语法,Vue基础语法,小清单练习)

    一.sorted面试题 面试题: [11, 33, 4, 2, 11, 4, 9, 2] 去重并保持原来的顺序 答案1: list1 = [11, 33, 4, 2, 11, 4, 9, 2] ret ...

随机推荐

  1. CF868F Yet Another Minimization Problem 分治决策单调性优化DP

    题意: 给定一个序列,你要将其分为k段,总的代价为每段的权值之和,求最小代价. 定义一段序列的权值为$\sum_{i = 1}^{n}{\binom{cnt_{i}}{2}}$,其中$cnt_{i}$ ...

  2. 【HDU3595】GG and MM(博弈论)

    [HDU3595]GG and MM(博弈论) 题面 HDU 一个游戏由多个游戏组成,每次每个操作者必须操作所有可以操作的游戏,操作集合为空者输. 每个游戏由两堆石子组成,每次可以从较多的那一堆中取走 ...

  3. [CF1131C]Birthday【贪心】

    题目描述 有 n n个数摆放在一个环形中(最后一个与第一个相邻),需要改变这些数的顺序,使得相邻两个数的最大绝对差最小.如果有多种最佳方案,输出任意一种. (翻译来自洛谷) 分析 首先收尾相接,那么很 ...

  4. su命令详解

    -----------------------------------------------------------------su 权限设置[root@localhost ~]# vim /etc ...

  5. [APIO2016]烟火表演

    题目描述 https://www.lydsy.com/JudgeOnline/problem.php?id=4585 题解 这题太神了. 我们可以先列出一个dp方程,dp[x][d]表示x节点到所有叶 ...

  6. 【mysql】mysql常用语句

    返回不重复数据 SELECT DISTINCT user_name,vistor_username FROM KY_FEED_VISTOR WHERE user_name='shenhy' 单独的di ...

  7. PHP函数memory_get_usage获取PHP内存清耗量

    (PHP 4 >= 4.3.2, PHP 5, PHP 7) memory_get_usage — 返回分配给 PHP 的内存量 说明 int memory_get_usage ([ bool ...

  8. poj2524(并查集水题)

    题目链接:http://poj.org/problem?id=2524 题目大意:学校共有n个同学,告诉你m对同学信仰同一宗教,问这个学校学生信仰宗教的数目最多为多少. 例: Sample Input ...

  9. CSS解决文字超出显示省略号问题

    超出一行 white-space: nowrap; overflow: hidden; text-overflow: ellipsis; 超出多行 overflow: hidden; text-ove ...

  10. isinstance,issubclass,内置函数__str__和__repr__,__format__,dir()函数

    isinstance(obj,cls) 检查是否obj是否是类 cls 的对象 #对象与类之间的关系 判断第一个参数是否是第二个参数的实例 # 身份运算 # 2 == 3 # 值是否相等# 2 is ...