vue-awesome-swiper滑塊插件使用方法詳解
更新時間:2022年01月27日 17:15:29 作者:大灰狼的小綿羊哥哥
這篇文章主要為大家詳細介紹了vue-awesome-swiper滑塊插件的使用方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了vue-awesome-swiper滑塊插件的使用方法,供大家參考,具體內容如下
1.進入項目目錄,安裝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是一個組件自有屬性,如果notNextTick設置為true,組件則不會通過NextTick來實例化swiper,也就意味著你可以在第一時間獲取到swiper對象,假如你需要剛加載遍使用獲取swiper對象來做什么事,那么這個屬性一定要是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ù),也應該出現(xiàn)在這個對象中,如下debugger // debugger: true, // swiper callbacks // swiper的各種回調函數(shù)也可以出現(xiàn)在這個對象中,和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 // 如果你需要得到當前的swiper對象來做一些事情,你可以像下面這樣定義一個方法屬性來獲取當前的swiper對象,同時notNextTick必須為true computed: { swiper() { return this.$refs.mySwiper.swiper } }, mounted() { // you can use current swiper instance object to do something(swiper methods) // 然后你就可以使用當前上下文內的swiper對象去做你想做的事了 // console.log('this is current swiper instance object', this.swiper) // this.swiper.slideTo(3, 1000, false) } } </script>
根據(jù)官方api進行調整
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
vue 驗證碼界面實現(xiàn)點擊后標灰并設置div按鈕不可點擊狀態(tài)
今天小編就為大家分享一篇vue 驗證碼界面實現(xiàn)點擊后標灰并設置div按鈕不可點擊狀態(tài),具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-10-10探秘Vue異步更新機制中nextTick的原理與實現(xiàn)
nextTick?是?Vue?提供的一個重要工具,它的作用主要體現(xiàn)在幫助我們更好地處理異步操作,下面就跟隨小編一起來探索一下nextTick的原理與實現(xiàn)吧2024-02-02Vue啟動失敗報錯:Module?not?found:?Error:?Can‘t?resolve?&apos
這篇文章主要給大家介紹了關于Vue啟動失敗報錯:Module?not?found:?Error:?Can‘t?resolve?'less-loader'解決的相關資料,文中通過圖文介紹的非常詳細,需要的朋友可以參考下2023-03-03