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

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

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

添加vue-awesome-swiper輪播組件

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

2.進(jìn)入項(xiàng)目目錄,安裝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是一個(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)
?}
}

5.最后引入swiper樣式

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

vue-awesome-swiper不輪播問(wèn)題

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

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

//輪播圖配置項(xiàng)

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

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

相關(guān)文章

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

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

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

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

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

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

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

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

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

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

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

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

    這篇文章主要介紹了Vuepress 搭建帶評(píng)論功能的靜態(tài)博客的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(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í)就是巧妙利用了原型和原型鏈來(lái)實(shí)現(xiàn)的。本文將通過(guò)示例為大家介紹下provide/inject的具體實(shí)現(xiàn),需要的可以參考一下
    2022-11-11
  • el-form 多層級(jí)表單的實(shí)現(xiàn)示例

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

    這篇文章主要介紹了el-form 多層級(jí)表單的實(shí)現(xiàn)示例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(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ì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-06-06
  • Vue 中文本內(nèi)容超出規(guī)定行數(shù)后展開(kāi)收起的處理的實(shí)現(xiàn)方法

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

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

最新評(píng)論

汪清县| 蒙阴县| 蚌埠市| 循化| 霸州市| 兴业县| 安庆市| 扶绥县| 岳西县| 保靖县| 莎车县| 郓城县| 孟津县| 八宿县| 阿尔山市| 黄山市| 米脂县| 普洱| 琼结县| 余干县| 九江市| 仙桃市| 新邵县| 二连浩特市| 绍兴县| 乐东| 阿合奇县| 晋城| 饶河县| 贵定县| 陆川县| 吉木乃县| 凤台县| 花垣县| 寿阳县| 丽江市| 大埔区| 龙口市| 易门县| 名山县| 县级市|