/* 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. winscp连接后目录名称乱码

    1.点击[编辑](点后变为保存按钮)按钮,高级按钮变为可用,点击[高级] 2.文件名utf-8编码,默认为“自动”,勾选为“开启”

  2. C++入门经典-关于extern变量

    1:extern用于解决使用非本源文件的全局变量. 例如:在sample1.cpp中 int a,b; /*外部变来那个定义*/ char c; void main() { cout<<a ...

  3. CppCheck介绍与使用

    版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/u011012932/article/details/52778149 简述 Cppcheck 是一种 ...

  4. vue中limitBy,filterBy,orderBy的用法

    1.limitBy的用法 <body> <div id="box"> <ul> <li v-for="val in arr | ...

  5. Use an Excel RTD Server with DCOM

    费好大劲找到的文章,留存. Use an Excel RTD Server with DCOM 如何使用DCOM的Excel RTD服务器 Microsoft Office Excel 2007,Mi ...

  6. day3_Python基础三

    参考:http://www.cnblogs.com/jin-xin/articles/7562422.html 一.数据类型 1.1.int:用于计算,不可变,可哈希 数字主要是用于计算用的: #bi ...

  7. 阶段3 2.Spring_07.银行转账案例_7 代理的分析

    新建项目 实现动态代理. 动态代理的概念 买电脑找代理商 代理的出现 解决了生产厂家的一些问题 需要java中的动态代理机制

  8. Oracle常用操作表空间sql脚本

    --删除用户(如果用户下面有对象,需要加cascade参数) drop user zxasrs cascade; --修改表空间为离线 alter tablespace zxasrs offline; ...

  9. JS中document对象 && window对象

    所有的全局函数和对象都属于Window对象的属性和方法. 区别: 1.window 指窗体.Window 对象表示浏览器中打开的窗口. document指页面.document是window的一个子对 ...

  10. cocos2dx基础篇(7) 触碰事件

    cocos2dx游戏引擎的重点是在于移动设备的跨平台开发,而移动设备上的游戏大部分都是通过屏幕触碰来进行的.比如主菜单的按钮触碰,打飞机中飞机的触碰移动,都需要用到触碰操作.想一想之前讲的菜单按钮CC ...