zoukankan      html  css  js  c++  java
  • vue中引入swiper(vue中的滑块组件vue-awesome-swiper)

    第一步安装

    npm install vue-awesome-swiper --save

    第二部在main.js中引入

    import VueAwesomeSwiper from 'vue-awesome-swiper'
    Vue.use(VueAwesomeSwiper)

    然后就可以在组件中使用该插件

    1. <template>  
    2.     <div>  
    3.         <swiper :options="swiperOption"  ref="mySwiper">  
    4.             <!-- 这部分放你要渲染的那些内容 -->  
    5.             <swiper-slide v-for="item in items">  
    6.             </swiper-slide>  
    7.             <!-- 这是轮播的小圆点 -->  
    8.             <div class="swiper-pagination" slot="pagination"></div>  
    9.         </swiper>  
    10.     </div>  
    11. </template>  
    12. <script>  
    13.     import { swiper, swiperSlide } from 'vue-awesome-swiper'  
    14.     export default {  
    15.         components: {  
    16.             swiper,  
    17.             swiperSlide  
    18.         },  
    19.         data() {  
    20.             return {  
    21.                 swiperOption: {  
    22.                 //是一个组件自有属性,如果notNextTick设置为true,组件则不会通过NextTick来实例化swiper,也就意味着你可以在第一时间获取到swiper对象,假如你需要刚加载遍使用获取swiper对象来做什么事,那么这个属性一定要是true  
    23.                 notNextTick: true,  
    24.                 pagination: '.swiper-pagination',  
    25.                 slidesPerView: 'auto',  
    26.                 centeredSlides: true,  
    27.                 paginationClickable: true,  
    28.                 spaceBetween: 30,  
    29.                     onSlideChangeEnd: swiper => {  
    30.                         //这个位置放swiper的回调方法  
    31.                         this.page = swiper.realIndex+1;  
    32.                         this.index = swiper.realIndex;  
    33.                     }  
    34.                 }  
    35.             }  
    36.         }
    37.     }  
    38. </script>  
    39. <style>  
    40. </style>  
  • 相关阅读:
    发现CSDN的一个小Bug,CSDN网站管理人员进来看看哈~~
    “凡客好声音”摇滚派对专场 正火热抢票中!
    帧动画
    java WEB Response重定向和缓存控制
    上一篇括号配对让人联想起catalan数,顺便转载一篇归纳的还不错的文章
    字符串循环移位
    应用层协议实现系列(三)——FTPserver之设计与实现
    HDU1575-Tr A(矩阵高速幂)
    音视频即时通讯的分包与重组
    怎样批量重命名照片,可是去掉那个烦人的括号
  • 原文地址:https://www.cnblogs.com/cina33blogs/p/6760820.html
Copyright © 2011-2022 走看看