国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 語(yǔ)言 > JavaScript > 正文

Vue中如何實(shí)現(xiàn)輪播圖的示例代碼

2024-05-06 15:13:47
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

這個(gè)功能我感覺(jué)在任何項(xiàng)目中都會(huì)涉及到,今天我就把我的實(shí)現(xiàn)方法跟大家分享一下,有不對(duì)的地方還請(qǐng)指出,我好更新。

下面是整體代碼,我把輪播圖單獨(dú)做了一個(gè)組件,大家可以拿來(lái)就用,具體代碼如下:

<template>  <div class="content">    <div class="focus">     <!-- focus begin -->     <swiper :options="swiperOption"><!-- map是數(shù)組 這里我們用v-for把數(shù)據(jù)循環(huán)出來(lái) -->      <swiper-slide v-for="item in map">       <a :href="item.i_route" rel="external nofollow" target="_blank">![](item.i_url)</a>     </swiper-slide>      <div class="swiper-pagination" slot="pagination"></div>     </swiper>     <!-- focus end -->     </div>  </div></template><script>//下面我們引用兩個(gè)插件,當(dāng)然,在使用之前請(qǐ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() {//通過(guò)接口獲取圖片數(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)注本站。

發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 武胜县| 枣阳市| 朝阳县| 景宁| 海门市| 镇安县| 华亭县| 宝兴县| 嘉峪关市| 香河县| 句容市| 营口市| 深水埗区| 金阳县| 泰顺县| 樟树市| 屯留县| 内丘县| 增城市| 望奎县| 营山县| 新昌县| 正宁县| 仙游县| 鲁山县| 甘德县| 卓资县| 尉氏县| 义马市| 安乡县| 泉州市| 岢岚县| 永宁县| 芦山县| 嵊州市| 张家界市| 凤山市| 绥棱县| 包头市| 延津县| 吉木萨尔县|