/* 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. jsp里面include的静态导入和动态导入的区别

    静态导入就是将被导入页面完全融入到导入的页面中:而动态导入只是在servlet里面插入了include方法,导入的这是被导入页面的body标签里面的内容 1.什么是静态导入? 静态导入指的是,将一个外 ...

  2. 第九周总结&实验报告七

    小结:这周请了一天的假,所以回来的时候有些知识点跟不上,不过在第二节课学到了关于IO的知识很重要,对于这次的实验也有些吃力,这周的知识点主要集中在书上,在各种不同条件下学习运用什么样的代码.   一. ...

  3. sudo密码一直出错

    Linux默认是没有将用户添加到sudoers列表中的,需要root手动将账户添加到sudoers列表中,才能让普通账户执行sudo命令. 所以要将用户添加到sudoers组中,才能执行sudo命令, ...

  4. shell脚本获取绝对路径

    当前脚本全路径 echo $(readlink -f "$0") 获取绝对路径(不带文件名) echo $(dirname $(readlink -f "$0" ...

  5. Cannot find terminfo entry for 'linux'.

    解决方案: 1. 查看 /usr/share/terminfo 目录下的内容,该目录的内容表示该主机支持哪些终端类型. 2. 通过修改系统变量TERM为vt100. 执行 export TERM=vt ...

  6. ListView的MyBaseAdapter的封装

    import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import j ...

  7. mysql的性能优化简介

    mysql性能下降的原因 sql语句本身有问题,或没建索引 索引失效,索引失效的原因本文后面会叙述 关联了过多的表,可能是前期设计缺陷,或者太奇葩的需求 服务器调优及参数设置,例如缓冲.线程等 mys ...

  8. Array数组对象

    1.数组方法: 1>字符串的连接: var myarr1= new Array("010") var myarr2= new Array("-",&quo ...

  9. java:struts框架(网路静态U盘项目)

    1.网络静态U盘项目: struts.xml: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYP ...

  10. 关机命令 shutdown

    参考资料:[http://jingyan.baidu.com/article/49ad8bce705f3f5834d8faec.html]