vue中swiper的使用教程

Install

創(chuàng)新互聯(lián)公司是一家集網(wǎng)站建設(shè),平度企業(yè)網(wǎng)站建設(shè),平度品牌網(wǎng)站建設(shè),網(wǎng)站定制,平度網(wǎng)站建設(shè)報(bào)價(jià),網(wǎng)絡(luò)營銷,網(wǎng)絡(luò)優(yōu)化,平度網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競(jìng)爭(zhēng)力。可充分滿足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時(shí)我們時(shí)刻保持專業(yè)、時(shí)尚、前沿,時(shí)刻以成就客戶成長(zhǎng)自我,堅(jiān)持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實(shí)用型網(wǎng)站。

在vue cli下的使用

npm

install vue-awesome-swiper --save

在main.js中

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

在component.vue中

<template>
<div id="container">
 <swiper :options="swiperOption" ref="mySwiper">
  <swiper-slide class="swiper-slide games">
   <img src="/src/assets/LB/LB_07.jpg" alt="">
  </swiper-slide>
  <swiper-slide class="swiper-slide games">
   <img src="/src/assets/LB/LB_06.jpg" alt="">
  </swiper-slide>
  <swiper-slide class="swiper-slide games">
   <img src="/src/assets/LB/LB_05.jpg" alt="">
  </swiper-slide>
  <swiper-slide class="swiper-slide games">
   <img src="/src/assets/LB/LB_04.jpg" alt="">
  </swiper-slide>
  <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>
 </swiper>   
 </div> 
 </template>
<script>
import { swiper, swiperSlide } from 'vue-awesome-swiper'
 export default {
  name: 'carrousel',
  data () {
   return {
    swiperOption: {
        autoplay : {
      disableOnInteraction: false, //用戶操作后是否禁止自動(dòng)循環(huán)
      delay: 3000 //自自動(dòng)循環(huán)時(shí)間
     }, //可選選項(xiàng),自動(dòng)滑動(dòng)
     speed: 2000, //切換速度,即slider自動(dòng)滑動(dòng)開始到結(jié)束的時(shí)間(單位ms)
     loop:true, //循環(huán)切換
     grabCursor: true, //設(shè)置為true時(shí),鼠標(biāo)覆蓋Swiper時(shí)指針會(huì)變成手掌形狀,拖動(dòng)時(shí)指針會(huì)變成抓手形狀
     // setWrapperSize: true, //Swiper使用flexbox布局(display: flex),開啟這個(gè)設(shè)定會(huì)在Wrapper上添加等于slides相加的寬或高,在對(duì)flexbox布局的支持不是很好的瀏覽器中可能需要用到。
     autoHeight: true,   //自動(dòng)高度。設(shè)置為true時(shí),wrapper和container會(huì)隨著當(dāng)前slide的高度而發(fā)生變化。   
     scrollbar: '.swiper-scrollbar',
     mousewheelControl: true, //設(shè)置為true時(shí),能使用鼠標(biāo)滾輪控制slide滑動(dòng)
     observeParents: true, //當(dāng)改變swiper的樣式(例如隱藏/顯示)或者修改swiper的子元素時(shí),自動(dòng)初始化swiper

     pagination: {
      el: '.swiper-pagination',
      // type : 'progressbar', //分頁器形狀
      clickable :true, //點(diǎn)擊分頁器的指示點(diǎn)分頁器會(huì)控制Swiper切換
     },
     navigation: {
      nextEl: '.swiper-button-next',
      prevEl: '.swiper-button-prev',
     },       
   },
   computed: {
    swiper() {
     return this.$refs.mySwiper.swiper
    }
   }
  }
 }
}
</script>
<style scoped>
img {
 width: 100%;
 height: auto;
}
</style>

參考:https://github.com/surmon-china/vue-awesome-swiper

https://surmon-china.github.io/vue-awesome-swiper/

總結(jié)

以上所述是小編給大家介紹的vue 中swiper的使用教程,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)創(chuàng)新互聯(lián)網(wǎng)站的支持!

當(dāng)前標(biāo)題:vue中swiper的使用教程
標(biāo)題URL:http://bm7419.com/article22/jdepjc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供動(dòng)態(tài)網(wǎng)站、虛擬主機(jī)、移動(dòng)網(wǎng)站建設(shè)、微信小程序用戶體驗(yàn)、定制開發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都app開發(fā)公司