Vue中如何實(shí)現(xiàn)輪播圖的示例代碼
更新時(shí)間:2017年07月27日 09:15:04 作者:陳楠酒肆
本篇文章主要介紹了Vue中如何實(shí)現(xiàn)輪播圖的示例代碼,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
這個(gè)功能我感覺在任何項(xiàng)目中都會(huì)涉及到,今天我就把我的實(shí)現(xiàn)方法跟大家分享一下,有不對的地方還請指出,我好更新。
下面是整體代碼,我把輪播圖單獨(dú)做了一個(gè)組件,大家可以拿來就用,具體代碼如下:
<template>
<div class="content">
<div class="focus">
<!-- focus begin -->
<swiper :options="swiperOption">
<!-- map是數(shù)組 這里我們用v-for把數(shù)據(jù)循環(huán)出來 -->
<swiper-slide v-for="item in map">
<a :href="item.i_route" rel="external nofollow" target="_blank"></a>
</swiper-slide>
<div class="swiper-pagination" slot="pagination"></div>
</swiper>
<!-- focus end -->
</div>
</div>
</template>
<script>
//下面我們引用兩個(gè)插件,當(dāng)然,在使用之前請先安裝
//安裝方法:npm install vue-awesome-swiper --save
import VueAwesomeSwiper from 'vue-awesome-swiper'
import { swiper, swiperSlide } from 'vue-awesome-swiper'
export default {
data() {
return {
swiperOption: {
autoplay: 5000,
initialSlide: 1,
loop: true,
pagination: '.swiper-pagination',
paginationClickable: true,
onSlideChangeEnd: swiper => {
//console.log('onSlideChangeEnd', swiper.realIndex)
}
}
}
},
mounted () {
this.bannerInfo();
},
components: {
swiper,
swiperSlide
},
methods: {
//輪播圖初始化
bannerInfo() {
//通過接口獲取圖片數(shù)據(jù)
this.$fetch('get/image/list').then(res => {
if(res.errCode == 200) {
this.map = res.errData;
}
});
}
}
}
</script>
以上就是實(shí)現(xiàn)輪播圖的全部代碼,有興趣的朋友可以試試看啦,希望大家繼續(xù)關(guān)注我們的網(wǎng)站!想要學(xué)習(xí)VUE的可以繼續(xù)關(guān)注本站。
您可能感興趣的文章:
- vue實(shí)現(xiàn)文字橫向無縫走馬燈組件效果的實(shí)例代碼
- vue實(shí)現(xiàn)圖片滾動(dòng)的示例代碼(類似走馬燈效果)
- vue.js整合mint-ui里的輪播圖實(shí)例代碼
- vue.js實(shí)現(xiàn)簡單輪播圖效果
- vue輪播圖插件vue-awesome-swiper的使用代碼實(shí)例
- Vue 過渡實(shí)現(xiàn)輪播圖效果
- 基于vue.js輪播組件vue-awesome-swiper實(shí)現(xiàn)輪播圖
- Vue項(xiàng)目中使用better-scroll實(shí)現(xiàn)一個(gè)輪播圖自動(dòng)播放功能
- vue2實(shí)現(xiàn)可復(fù)用的輪播圖carousel組件詳解
- Vue.js輪播圖走馬燈代碼實(shí)例(全)
相關(guān)文章
vue+webpack實(shí)現(xiàn)異步組件加載的方法
下面小編就為大家分享一篇vue+webpack實(shí)現(xiàn)異步組件加載的方法,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-02-02
VUE實(shí)現(xiàn)移動(dòng)端列表篩選功能
這篇文章主要介紹了VUE實(shí)現(xiàn)移動(dòng)端列表篩選功能,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-08-08
使用vue中的混入mixin優(yōu)化表單驗(yàn)證插件問題
這篇文章主要介紹了使用vue中的混入mixin優(yōu)化表單驗(yàn)證插件,本文是小編給大家總結(jié)的一些表單插件的問題,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-07-07

