Vue中如何实现轮播图的示例代码
网络编程 2021-07-04 18:32www.168986.cn编程入门
本篇文章主要介绍了Vue中如何实现轮播图的示例代码,长沙网络推广觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随长沙网络推广过来看看吧
这个功能我感觉在任何项目中都会涉及到,今天我就把我的实现方法跟大家分享一下,有不对的地方还请指出,我好更新。
狼蚁网站SEO优化是整体代码,我把轮播图单独做了一个组件,大家可以拿来就用,具体代码如下:
<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">![](item.i_url)</a> </swiper-slide> <div class="swiper-pagination" slot="pagination"></div> </swiper> <!-- focus end --> </div> </div> </template> <script> //狼蚁网站SEO优化我们引用两个插件,当然,在使用之前请先安装 //安装方法:npm install vue-awesome-swiper --save import VueAwesomeSwiper from 'vue-awesome-swiper' import { swiper, swiperSlide } from 'vue-awesome-swiper' export default { data() { return { swiperOption: { aulay: 5000, initialSlide: 1, loop: true, pagination: '.swiper-pagination', paginationClickable: true, onSlideChangeEnd: swiper => { //console.log('onSlideChangeEnd', swiper.realIndex) } } } }, mounted () { this.bannerInfo(); }, ponents: { swiper, swiperSlide }, methods: { //轮播图初始化 bannerInfo() { //通过接口获取图片数据 this.$fetch('get/image/list').then(res => { if(res.errCode == 200) { this.map = res.errData; } }); } } } </script>
以上就是实现轮播图的全部代码,有兴趣的朋友可以试试看啦,希望大家继续关注我们的网站!想要学习VUE的可以继续关注本站。
编程语言
- 机械手焊接机器人编程 机械手焊接设备编程
- vb数据库编程实例,vb做数据库
- tiobe世界编程语言排行榜,全球编程语言排行
- 成都java编程培训 成都it编程培训中心
- 编程基础培训,编程基础知识培训
- flash游戏编程基础教程,flash游戏开发教程
- 不会英语能学编程吗 不会英语可以学程序员吗
- 爱心代码编程C语言 爱心代码编程c语言公式
- c语言编程学习入门 c语言编程快速入门
- 西门子plc编程培训 西门子plc编程培训班
- 哪里可以学编程 台州哪里可以学编程
- 少儿编程哪个好 少儿编程哪个品牌好
- 编程是什么意思,图形编程是什么意思
- c语言编程软件下载,c语言编程软件在哪下载
- java编程软件下载,java编程下载手机版
- ug编程培训学校,ug编程培训教程