写博客不是我的爱好,只是人脑毕竟空间只有那么大,有时候会忘了,好记性不如烂笔头,所以通过博客记录点点滴滴,以后可以翻出来看。

vue-awesome-swiper官网链接https://www.npmjs.com/package/vue-awesome-swiper

和上一篇随笔一样,我们先下载包,然后去main.js里面配置。

1
npm install vue-awesome-swiper --save

  我们可以用import的方法

1
2
3
// import
import Vue from 'vue'
import VueAwesomeSwiper from 'vue-awesome-swiper'

  也可以用require

1
2
var Vue = require('vue')
var VueAwesomeSwiper = require('vue-awesome-swiper')

  两者都可以达到目的,然后再mian.js里面全局注册

1
Vue.use(VueAwesomeSwiper)

  在模板里使用

1
2
3
4
5
6
7
8
import { swiper, swiperSlide } from 'vue-awesome-swiper'
 
export default {
components: {
swiper,
swiperSlide
}
}

  

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
43
44
45
46
47
48
<template>
<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>
<swiper-slide>I'm Slide 5</swiper-slide>
<swiper-slide>I'm Slide 6</swiper-slide>
<swiper-slide>I'm Slide 7</swiper-slide>
<!-- Optional controls -->
<div class="swiper-pagination" slot="pagination"></div>//
<div class="swiper-button-prev" slot="button-prev"></div>
<div class="swiper-button-next" slot="button-next"></div>
<div class="swiper-scrollbar" slot="scrollbar"></div>
</swiper>
</template>
 
<script>gt;
// swiper options example:
export default {
name: 'carrousel',
data() {
return {
swiperOption: {//以下配置不懂的,可以去swiper官网看api,链接http://www.swiper.com.cn/api/
// notNextTick是一个组件自有属性,如果notNextTick设置为true,组件则不会通过NextTick来实例化swiper,也就意味着你可以在第一时间获取到swiper对象,<br>        假如你需要刚加载遍使用获取swiper对象来做什么事,那么这个属性一定要是true
notNextTick: true,
// swiper configs 所有的配置同swiper官方api配置
autoplay: 3000,
direction : 'vertical',
grabCursor : true,
setWrapperSize :true,
autoHeight: true,
pagination : '.swiper-pagination',
paginationClickable :true,
prevButton:'.swiper-button-prev',//上一张
nextButton:'.swiper-button-next',//下一张
scrollbar:'.swiper-scrollbar',//滚动条
mousewheelControl : true,
observeParents:true,
// 如果自行设计了插件,那么插件的一些配置相关参数,也应该出现在这个对象中,如下debugger
debugger: true,
}
}
},
 
}
</script>

  这样就可以使用啦

<-----------------------补充时间2017/9/22 21:00------------------------>

平时没怎么用这个插件,今天看了下,发现有点小小的改动,可能导致之前的受到影响,npm包发布者的原话是

// starting with version 2.6.0, you need to manually introduce swiper's css这句话的意思是:从版本2.6.0开始,您需要手动引入swiper的css
import 'swiper/dist/css/swiper.css'

我写这篇随笔的时候,还是2.4.2版本,还没有更新到2.6.0版本,所以并没有什么样式上的问题,今天我更新了包试了一下之前写的,发现样式上出问题了。所以才去找的文档,在此补充,希望能帮到各位

vue-swiper的使用的更多相关文章

  1. vue swiper上下无缝轮播

    参考:https://www.jianshu.com/p/5e5e59065e9c 效果: index.html: <link href="https://cdn.bootcss.co ...

  2. vue swiper异步加载轮播图,并且懒加载

    参考:https://blog.csdn.net/weixin_38304202/article/details/78282826 效果: 此处安装省略 vue: <div class=&quo ...

  3. vue swiper中的大坑

    mounted() { var self = this; for (var i = 0; i < self.$refs.mySwiper.swiper.pagination.bullets.le ...

  4. vue swiper点击后返回不能自动播放

    解决方法: 在返回时重新开启轮播 组件中: <swiper :options="swiperOption" ref="mySwiper" :class=& ...

  5. VUE swiper.js引用使用轮播图

    <template> <div class="home"> <div class="swiper-container"> & ...

  6. swiper实现臭美app滑动效果

    一.臭美app效果: 我的需求是这样,上面正常滑动,点击下面的小卡牌,上面的滑动区也随之切换到当前的点击态. 二.实现: css: 主要设置可见区域的几张卡牌的位置,注意的几个位置是,中间的激活态和左 ...

  7. vue轮播(完整详细版)

    轮播组件vue <swiper :options="swiperOption" class='swiper-box'>     <swiper-slide v-f ...

  8. 5.【nuxt起步】-swiper组件

    接下来是一个比较常用,也比较重要的组件 swiper,可以自行搜索 vue swiper,有很多开源组件,我这里就复用之前一个熟悉的, 1.新建component/banner.vue 刷新报错: 要 ...

  9. Vue.js开发去哪儿网WebApp

    一.项目介绍 这个项目主要参考了去哪儿网的布局,完成了首页.城市选择页面.详情页面的开发. 首页:实现了多区域轮播的功能,以及多区域列表的展示: 城市选择页面:在这个页面实现了城市展示.城市搜索.城市 ...

  10. 类似今日头条,头部tab可滑动,下面的内容可跟着滚动,掺杂着vue和require等用法例子

    1.在main.js里 /*主模块的入口 结合require一起使用*/ require.config({//require的基础用法 配置一下 paths: { "Zepto" ...

随机推荐

  1. (JAVA保留小数问题,基础)Probability hdu2131

    Probability 链接:http://acm.hdu.edu.cn/showproblem.php?pid=2131 Time Limit: 3000/1000 MS (Java/Others) ...

  2. python---RabbitMQ(1)简单队列使用,消息依次分发(一对一),消息持久化处理

    MQ全称为Message Queue, 消息队列(MQ)是一种应用程序对应用程序的通信方法.应用程序通过读写出入队列的消息(针对应用程序的数据)来通信,而无需专用连接来链接它们.消息传递指的是程序之间 ...

  3. Frame size of 257 MB larger than max allowed 100 MB

    ActiveMQ有时会报类似Frame size of 257 MB larger than max allowed 100 MB的错误,意思是单条消息超过了预设的最大值,在配置文件中 <tra ...

  4. C# CEF 封装UserControl

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; u ...

  5. ELF文件解析(二):ELF header详解

    上一篇讲了ELF文件的总体布局,以及section和segment的概念.按照计划,今天继续讲 ELF header. 讲新的内容之前,先更正一个错误:上一篇中讲section header tabl ...

  6. qemu基本使用

    1.qemu的安装 请参考家用路由器0day漏洞挖掘技术这本书 2.基本使用 qemu有主要如下两种运作模式: 用户模式(User Mode),亦称使用者模式.qemu能启动那些为不同中央处理器编译的 ...

  7. static, const

    static 静态的,类的静态成员函数,静态成员变量是和类相关的,但不和具体对象相关.即使没有具体对象,也能调用类的静态成员函数和成员变量.一般类的静态函数就是一个全局函数,只是作用域在包含它的文件中 ...

  8. 嵌入式iframe子页面与父页面js通信方式

    iframe框架中的页面与主页面之间的通信方式根据iframe中src属性是同域链接还是跨域链接,有明显不同的通信方式,同域下的数据交换和DOM元素互访就简单的多了,而跨域的则需要一些巧妙的方式来实现 ...

  9. Linux - openssl 加密

    openssl rand 15 -base64 # 口令生成 openssl sha1 filename # 哈希算法校验文件 openssl md5 filename # MD5校验文件 opens ...

  10. luogu P2325 [SCOI2005]王室联邦

    传送门 做法是dfs整棵树,当访问一个点\(x\)时,先访问儿子,若某个时刻子树大小\(\ge b\)时,就把那些点放在一个省里,省会记为\(x\),访问完儿子再把\(x\)加入栈.最后栈中剩余的没加 ...