這個功能我感覺在任何項目中都會涉及到,今天我就把我的實現方法跟大家分享一下,有不對的地方還請指出,我好更新。
站在用戶的角度思考問題,與客戶深入溝通,找到銀川網站設計與銀川網站推廣的解決方案,憑借多年的經驗,讓設計與互聯網技術結合,創造個性化、用戶體驗好的作品,建站類型包括:網站建設、成都網站建設、企業官網、英文網站、手機端網站、網站推廣、國際域名空間、雅安服務器托管、企業郵箱。業務覆蓋銀川地區。
下面是整體代碼,我把輪播圖單獨做了一個組件,大家可以拿來就用,具體代碼如下:
<template> <div class="content"> <div class="focus"> <!-- focus begin --> <swiper :options="swiperOption"> <!-- map是數組 這里我們用v-for把數據循環出來 --> <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> //下面我們引用兩個插件,當然,在使用之前請先安裝 //安裝方法: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() { //通過接口獲取圖片數據 this.$fetch('get/image/list').then(res => { if(res.errCode == 200) { this.map = res.errData; } }); } } } </script>
以上就是實現輪播圖的全部代碼,有興趣的朋友可以試試看啦,希望大家繼續關注我們的網站!想要學習VUE的可以繼續關注本站。
文章題目:Vue中如何實現輪播圖的示例代碼
轉載來源:http://vcdvsql.cn/article20/peshco.html
成都網站建設公司_創新互聯,為您提供搜索引擎優化、品牌網站制作、網站營銷、動態網站、做網站、網站內鏈
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯