最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue添加vue-awesome-swiper輪播組件方式

 更新時間:2022年10月21日 09:27:41   作者:騎上我心愛的小摩托  
這篇文章主要介紹了vue添加vue-awesome-swiper輪播組件方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教

添加vue-awesome-swiper輪播組件

1.vue項目中添加swiper組件,也是很常見的,通常在jQuery中的方法,其實(shí)并不適用于vue項目。vue由于自身的框架性問題不依賴于jQuery,所以vue最好是用自己本身的swiper內(nèi)置標(biāo)簽

2.進(jìn)入項目目錄,安裝swiper

npm install vue-awesome-swiper --save

3.在main.js中定義該swiper組件

import Vue from 'vue'
//掛載swiper
import VueAwesomeSwiper from 'vue-awesome-swiper';
Vue.use(VueAwesomeSwiper);

4.在代碼中插入該swiper標(biāo)簽

<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>

并進(jìn)行swiper的配置

import { swiper, swiperSlide } from 'vue-awesome-swiper'

數(shù)據(jù)方法配置

export default {
? name: '',
?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設(shè)置為true,組件則不會通過NextTick來實(shí)例化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è)計了插件,那么插件的一些配置相關(guān)參數(shù),也應(yīng)該出現(xiàn)在這個對象中,如下debugger
? ? ? ?// debugger: true,
? ? ? ?// swiper callbacks
? ? ? ?// swiper的各種回調(diào)函數(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
?// 如果你需要得到當(dāng)前的swiper對象來做一些事情,你可以像下面這樣定義一個方法屬性來獲取當(dāng)前的swiper對象,同時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對象去做你想做的事了
? ?// console.log('this is current swiper instance object', this.swiper)
? ?// this.swiper.slideTo(3, 1000, false)
?}
}

5.最后引入swiper樣式

@import'../src/style/swiper.min.css';

vue-awesome-swiper不輪播問題

因?yàn)閟wiper渲染的時候數(shù)據(jù)還沒有加載完畢,所以swiper就不輪播了,加一個判斷就好

<div class="banner-wrap" ? v-if='bannerList.length'>?
? ? ? ??
? ? ? ? <swiper :options="swiperOption" ref="mySwiper" >
? ? ? ? ? ? <swiper-slide v-for='(item,index) in bannerList' :key = 'index'>
? ? ? ? ? ? ? ? <div class="img-box">
? ? ? ? ? ? ? ? ? <img :src="item.banner" alt="">
? ? ? ? ? ? ? ? </div>
? ? ? ? ? ? </swiper-slide>?
? ? ? ? ? ? <div class="swiper-pagination" ?slot="pagination"></div>
? ? ? ? </swiper>
? ? ? </div>

//輪播圖配置項

? swiperOption: {
? ? ? loop:true,
? ? ? autoplay:{
? ? ? ? ? disableOnInteraction: false,
? ? ? ? ? delay: 2000,
? ? ? },
? ? ? pagination: {
? ? ? ? ? el:'.swiper-pagination',
? ? ? ? ? clickable:true,
? ? ? ? ? // type:"bullets",
? ? ? ? ?
? ? ? },
? ? ? autoplayDisableOnInteraction: false,
? },

以上為個人經(jīng)驗(yàn),希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • vue單向以及雙向數(shù)據(jù)綁定方式(v-bind和v-model的使用)

    vue單向以及雙向數(shù)據(jù)綁定方式(v-bind和v-model的使用)

    這篇文章主要介紹了vue單向以及雙向數(shù)據(jù)綁定方式(v-bind和v-model的使用),具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-04-04
  • Vue.js彈出模態(tài)框組件開發(fā)的示例代碼

    Vue.js彈出模態(tài)框組件開發(fā)的示例代碼

    本篇文章主要介紹了Vue.js彈出模態(tài)框組件開發(fā)的示例代碼,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-07-07
  • 關(guān)于axios不能使用Vue.use()淺析

    關(guān)于axios不能使用Vue.use()淺析

    這篇文章主要給大家介紹了關(guān)于axios不能使用Vue.use()的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的理解和學(xué)習(xí)具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考借鑒,下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。
    2018-01-01
  • Vue3中Cesium地圖初始化及地圖控件配置方法

    Vue3中Cesium地圖初始化及地圖控件配置方法

    本文中,我們主要介紹Cesium在Vue3運(yùn)行環(huán)境的配置,及Cesium實(shí)例中控件的顯隱設(shè)置,本項目基于pnpm安裝,也可使用其他包管理器進(jìn)行安裝,如npm或yarn,本文通過示例代碼對vue初始化Cesium地圖相關(guān)知識介紹的非常詳細(xì),需要的朋友參考下吧
    2023-07-07
  • 使用table做成樹形結(jié)構(gòu)的table

    使用table做成樹形結(jié)構(gòu)的table

    這篇文章主要介紹了使用table做成樹形結(jié)構(gòu)的table問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-07-07
  • Vuepress 搭建帶評論功能的靜態(tài)博客的實(shí)現(xiàn)

    Vuepress 搭建帶評論功能的靜態(tài)博客的實(shí)現(xiàn)

    這篇文章主要介紹了Vuepress 搭建帶評論功能的靜態(tài)博客的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-02-02
  • Vue3實(shí)現(xiàn)provide/inject的示例詳解

    Vue3實(shí)現(xiàn)provide/inject的示例詳解

    Vue3 的 Provide / Inject 的實(shí)現(xiàn)原理其實(shí)就是巧妙利用了原型和原型鏈來實(shí)現(xiàn)的。本文將通過示例為大家介紹下provide/inject的具體實(shí)現(xiàn),需要的可以參考一下
    2022-11-11
  • el-form 多層級表單的實(shí)現(xiàn)示例

    el-form 多層級表單的實(shí)現(xiàn)示例

    這篇文章主要介紹了el-form 多層級表單的實(shí)現(xiàn)示例,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-09-09
  • vue+axios+java實(shí)現(xiàn)文件上傳功能

    vue+axios+java實(shí)現(xiàn)文件上傳功能

    這篇文章主要為大家詳細(xì)介紹了vue+axios+java實(shí)現(xiàn)文件上傳功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-06-06
  • Vue 中文本內(nèi)容超出規(guī)定行數(shù)后展開收起的處理的實(shí)現(xiàn)方法

    Vue 中文本內(nèi)容超出規(guī)定行數(shù)后展開收起的處理的實(shí)現(xiàn)方法

    這篇文章主要介紹了Vue 中文本內(nèi)容超出規(guī)定行數(shù)后展開收起的處理的實(shí)現(xiàn)方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-04-04

最新評論

定兴县| 壶关县| 仲巴县| 阜城县| 固阳县| 吉林省| 德兴市| 房山区| 大名县| 朝阳区| 潍坊市| 贵南县| 拜城县| 广汉市| 武夷山市| 茂名市| 庄浪县| 平湖市| 曲阜市| 雷山县| 泽州县| 汝阳县| 湖口县| 定结县| 探索| 湖北省| 新源县| 阿尔山市| 钦州市| 秦皇岛市| 望奎县| 高安市| 通河县| 和硕县| 秀山| 安西县| 临桂县| 桐柏县| 威远县| 澄江县| 六安市|