/* Start  基本样式*/
* {
  margin: 0;
  padding: 0;
}
ul {
  list-style-type: none;
}
body {
  font-size: 14px;
  background: #fff;
  overflow-y: scroll;
  overflow-x: hidden;
}
html,
body {
  /* max-width: 720px; */
  height: 100%;
  margin: 0 auto;
}
/* End 基本样式 */
.banner{
  width: 100%;
}
.item{
  width: 100%;
  display: flex;
  flex-direction: row;
}
.item img{
  width: 100%;
}
.page{
    display: flex;
    flex-direction: row;
    width: 100%;
    position: absolute;
    bottom: 20px;
}
.page ul{
display: flex;
    flex-direction: row;
    margin: 0 auto;
}
.page li{
  padding:0 5px;
}
.number:hover{
  color: red;
  font-weight: bold;
}
 
 
 // 圆点的点击事件
    gotoPage (index) {
      // 将index赋值给图片的下标currentIndex
      this.currentIndex = index
    },
    // 点击事件的函数
    // 上一张
    prevIndex () {
      // eslint-disable-next-line eqeqeq
      if (this.currentIndex == 0) {
        return this.dataList.length - 1
      } else {
        return this.currentIndex - 1
      }
    },
    // 下一张
    nextIndex () {
      // eslint-disable-next-line eqeqeq
      if (this.currentIndex == this.dataList.length - 1) {
        return 0
      } else {
        return this.currentIndex + 1
      }
    },
    // 定时器
    runInv () {
      this.timer = setInterval(() => {
        this.gotoPage(this.nextIndex)
      }, 1000)
    }
  }
 
data () {
    return {
      dataList: ['https://i1.mifile.cn/a4/xmad_15535933141925_ulkYv.jpg', 'https://i1.mifile.cn/a4/xmad_15532384207972_iJXSx.jpg', 'https://i1.mifile.cn/a4/xmad_15517939170939_oiXCK.jpg'],
      currentIndex: 0, // 默认显示图片
      timer: null // 定时器
    }
 
 <div class="banner">
      <div class="item">
        <img :src="dataList[currentIndex]" alt="加载中。。。">
      </div>
      <div class="page" v-if="this.dataList.length > 1">
        <ul>
          <li @click="gotoPage(prevIndex)">&lt;</li>
          <li v-for="(item,index) in dataList" @click="gotoPage(index)" :class="{'current':currentIndex == index}" v-bind:key="index" class="number">{{index+1}}</li>
          <li @click="gotoPage(nextIndex)">&gt;</li>
        </ul>
      </div>
    </div>
 
 

vue实现轮播图的更多相关文章

  1. vue自定义轮播图组件 swiper

    1.banner 组件 components/Banner.vue <!-- 轮播图 组件 --> <template> <div class="swiper- ...

  2. vue+mui轮播图

    mui的轮播图,如果图片是请求来的,直接在html中循环是不会动的. 需要请求完图片之后,在setTimeout方法里,使用slider()方法,这样才会动 而且mui的轮播图,有点坑的,需要重复最后 ...

  3. vue项目轮播图的实现

    利用   Vue-Awesome-Swiper插件来做轮播效果,github地址:https://github.com/surmon-china/vue-awesome-swiper 安装 npm i ...

  4. vue简易轮播图

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  5. vue中轮播图的实现

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. vue编写轮播图组件

    <template>  <div id="slider">    <div class="window" @mouseover=& ...

  7. vue music-抓取歌单列表数据(渲染轮播图)

    下载安装新依赖 babel-runtime:对es6语法进行转译 fastclick:对移动端进行点击300毫秒延迟 ,,取消掉 babel-polyfill:API 先添加,在npm install ...

  8. vue轮播图

    vue开发中遇到这样一个需求实现导航栏和中间内容相结合实现页面滑动导航跟随改变的效果.看效果: 这里我用的是vue所带的插件:vue-awesome-swiper,传送门:https://www.np ...

  9. vue-awesome-swiper 轮播图使用

    最近在做vue 的轮播图的问题,项目中也遇到一些问题,查了 swiper 官网资料, 还有vue-awesome-swiper的文案,最后把怎么使用这个插件简单的说下,啥东西都需要自己实践下,还是老规 ...

随机推荐

  1. 191121CSS

    一.CSS 1.css选择器 css选择器的使用方法 <!DOCTYPE html> <html lang="en"> <head> <m ...

  2. JDBC连接数据库遇到的“驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。

    要从旧算法列表中删除3DES: 在JDK 8及更早版本中,编辑该 /lib/security/java.security文件并3DES_EDE_CBC从jdk.tls.legacyAlgorithms ...

  3. linux(centOS7)的基本操作(五) 磁盘、分区、挂载、卸载

    linux的磁盘类型和分区简介 linux的磁盘分为IDE和SCSI,目前以后者居多. 1. IDE磁盘的分区:hd+盘号+分区数字 盘号 |-a:基本盘 |-b:基本从属盘 |-c:辅助主盘 |-d ...

  4. VirtualBox上Centos7磁盘扩容

    VirtualBox上Centos7磁盘扩容 非常实用 点击直达

  5. pureftp安装部署

    ftp:文件传输pure-ftpd:ftp软件作用:通过映射登录传送和接收文件.1.先下载pure-ftpd软件,最好指定一个下载软件目录如:/usr/local/src wget https://d ...

  6. 阶段3 2.Spring_01.Spring框架简介_01.spring课程四天安排

    spring共四天 第一天:spring框架的概述以及spring中基于XML的IOC配置 第二天:spring中基于注解的IOC和ioc的案例 第三天:spring中的aop和基于XML以及注解的A ...

  7. Git使用手册/Git教程:git fetch 将远程仓库的分支及分支最新版本代码拉取到本地

    相关文章: 关于验证是否存在ssh配置以及生成SSH Key的方法可以参照文章:Git使用手册:生成SSH Key 关于SSH Key的使用和公钥在gitHub.gitLab的配置等,请参考文章:Gi ...

  8. 清除陷入CLOSE_WAIT的进程

    netstat -nap |grep :8009|grep CLOSE_WAIT | awk '{print $7}'|awk -F"\/" '{print $1}' |awk ' ...

  9. 转载 STM32 使用Cubemx 建一个USB(HID)设备下位机,实现数据收发

    STM32 使用Cubemx 建一个USB(HID)设备下位机,实现数据收发  本文转载自 https://www.cnblogs.com/xingboy/p/9913963.html 这里我主要说一 ...

  10. CSS3 长度单位

    http://www.w3chtml.com/css3/units/length/vh.html https://www.html.cn/book/css/values/length/vh.htm . ...