溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

vue-awesome-swiper滑塊插件使用方法詳解

發(fā)布時(shí)間:2020-08-23 09:52:09 來(lái)源:腳本之家 閱讀:413 作者:大灰狼的小綿羊哥哥 欄目:web開(kāi)發(fā)

本文實(shí)例為大家分享了Android九宮格圖片展示的具體代碼,供大家參考,具體內(nèi)容如下

github地址: https://github.com/surmon-china/vue-awesome-swiper.git

1.進(jìn)入項(xiàng)目目錄,安裝swiper

npm install vue-awesome-swiper --save

2.引入資源

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

3.編輯組件

<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>
import { swiper, swiperSlide } from 'vue-awesome-swiper'
export default {
 name: 'carrousel',
 data() {
 return {
  swiperOption: {
  // NotNextTick is a component's own property, and if notNextTick is set to true, the component will not instantiate the swiper through NextTick, which means you can get the swiper object the first time (if you need to use the get swiper object to do what Things, then this property must be true)
  // notNextTick是一個(gè)組件自有屬性,如果notNextTick設(shè)置為true,組件則不會(huì)通過(guò)NextTick來(lái)實(shí)例化swiper,也就意味著你可以在第一時(shí)間獲取到swiper對(duì)象,假如你需要?jiǎng)偧虞d遍使用獲取swiper對(duì)象來(lái)做什么事,那么這個(gè)屬性一定要是true
  notNextTick: true,
  // swiper configs 所有的配置同swiper官方api配置
  autoplay: 3000,
  // direction : 'vertical',
  effect:"coverflow",
  grabCursor : true,
  setWrapperSize :true,
  // autoHeight: true,
  // paginationType:"bullets",
  pagination : '.swiper-pagination',
  paginationClickable :true,
  prevButton:'.swiper-button-prev',
  nextButton:'.swiper-button-next',
  // scrollbar:'.swiper-scrollbar',
  mousewheelControl : true,
  observeParents:true,
  // if you need use plugins in the swiper, you can config in here like this
  // 如果自行設(shè)計(jì)了插件,那么插件的一些配置相關(guān)參數(shù),也應(yīng)該出現(xiàn)在這個(gè)對(duì)象中,如下debugger
  // debugger: true,
  // swiper callbacks
  // swiper的各種回調(diào)函數(shù)也可以出現(xiàn)在這個(gè)對(duì)象中,和swiper官方一樣
  // onTransitionStart(swiper){
  // console.log(swiper)
  // },
  // more Swiper configs and callbacks...
  // ...
  }
 }
 },components: {
 swiper,
 swiperSlide
},
 // you can find current swiper instance object like this, while the notNextTick property value must be true
 // 如果你需要得到當(dāng)前的swiper對(duì)象來(lái)做一些事情,你可以像下面這樣定義一個(gè)方法屬性來(lái)獲取當(dāng)前的swiper對(duì)象,同時(shí)notNextTick必須為true
 computed: {
 swiper() {
  return this.$refs.mySwiper.swiper
 }
 },
 mounted() {
 // you can use current swiper instance object to do something(swiper methods)
 // 然后你就可以使用當(dāng)前上下文內(nèi)的swiper對(duì)象去做你想做的事了
 // console.log('this is current swiper instance object', this.swiper)
 // this.swiper.slideTo(3, 1000, false)
 }
}
</script>

根據(jù)官方api進(jìn)行調(diào)整

http://www.swiper.com.cn/api/pagination/2016/0126/299.html

vue-awesome-swiper滑塊插件使用方法詳解

我的git demo可以參考 :https://github.com/ssdpj/mk/tree/vue-admine

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持億速云。

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI