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

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. Exception in thread "main" org.springframework.beans.factory.NoSuchBeanDefinitionException

    今天在学习spring 框架的时候看着,很简单.但是在真正开始做的时候发现,异常一个接着一个,整的肚子都被搞大了. Exception in thread "main" org.s ...

  2. 【Python】统计个人新浪微博词频并给出相应的柱状图

    Python爬虫视频教程零基础小白到scrapy爬虫高手-轻松入门 https://item.taobao.com/item.htm?spm=a1z38n.10677092.0.0.482434a6E ...

  3. CF786B Legacy && 线段树优化连边

    线段树优化连边 要求点 \(x\) 向区间 \([L, R]\) 连边, 一次的复杂度上限为 \(O(n)\) 然后弄成线段树的结构 先父子连边边权为 \(0\) 这样连边就只需要连父亲就可以等效于连 ...

  4. Python基础数据类型-列表(list)和元组(tuple)和集合(set)

    Python基础数据类型-列表(list)和元组(tuple)和集合(set) 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 本篇博客使用的是Python3.6版本,以及以后分享的 ...

  5. golang匿名结构体

    go语言定义结构体类型时可以仅指定字段类型而不指定字段名字.这种字段叫做匿名字段(anonymous field). Go语言有一个特性允许只声明一个成员对应的数据类型而不指名成员的名字:这类成员就 ...

  6. 《高性能Mysql》讲聚簇索引

    <高性能Mysql>原文 聚簇索引如下图为聚簇所有的存储方式,聚簇实际不是一种索引,而是一种数据的存储方式,InnoDB的聚簇事假在同一个结构中保存了B-Tree索引和数据行. 当表有聚簇 ...

  7. ATS metric query

    ATS metric query 参考:ATS metric query proxy.node.cache_hit_mem_ratio proxy.node.cache_hit_mem_ratio_a ...

  8. Mac下使用Wine安装PowerDesigner15

    下载: (链接: https://pan.baidu.com/s/1bpEYyIV 密码: 5ymj) 安装: 1.安装Wine 参考:http://www.cnblogs.com/EasonJim/ ...

  9. 02、@PropertySource指定配置文件的属性映射到JavaBean属性

    零.@PropertySource 功能类似于 <context:property-placeholder location="classpath*:/config/load.prop ...

  10. 2018秋寒假作业6- -PTA编程总结3

    PTA3抓老鼠啊~亏了还是赚了?思路: 首先定义变量并初始化为零,然后用if-else语句判断其关系和计算奶酪数量及盈利情况.