/* 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. vscode 配置go环境 可调试

      1.go下载安装并配置环境变量 2.安装工具: 1)安装gocode go get -u -v github.com/nsf/gocode 2)安装godef go get -u -v githu ...

  2. vue网址路由的实时检测

    有些时候,我们需要实时的检测网址,来进行判断,操作,处理等等 我们需要使用 watch 的监视器,然后直接进行操作 我们需要 ’$route.path‘   属性来进行监听,且需要加引号,然后只要页面 ...

  3. 验证TXT解析的正确性

    需要用到TXT解析,不同于CNAME和A解析,可以用PING命令验证,要验证TXT解析需要用到如下命令 nslookup -q=TXT txtdemo.lei.cool 8.8.8.8 输出内容如下 ...

  4. DeepFaceLab进阶:H128,DF,SAE模型有何不同?哪个最好?

    整个换脸过程中模型是最重要的一部分,耗时久,调优难,很多人虽然一直在跑模型,却并不知道每个模型的特点. 我也常常被问及: 到底用哪个模型换脸效果最好? H128和DF有什么差别? H64和H28有什么 ...

  5. vue问题二:vue打包时产生的问题

    vue项目打包问题:vue中默认的config/index.js的配置的详细理解: 参考文档:https://blog.csdn.net/qq_34611721/article/details/809 ...

  6. 获取当前线程状态--Thread类

    String msgToPrint = Thread.currentThread().getStackTrace()[3] .getMethodName(); 就是调用时的方法名. 其中使用的Thre ...

  7. 非GUI运行Jmeter,jtl文件没有响应数据的解决办法

    一.问题 Jmeter官方一直强调要在非GUI模式下运行Jmeter:Run your JMeter test in command-line non-GUI mode. 但在非GUI模式下运行生成的 ...

  8. java:CSS(定位,组合选择符,边距,Float,Table的样式,显示和隐藏,换行,盒子模型,iframe和frameset框架)

    1.绝对定位,相对定位,fixed定位(指浏览器窗口定位): <!DOCTYPE html> <html> <head> <meta charset=&quo ...

  9. css换行用省略号代替

    css换行用省略号代替,也可以说是长标题的文章可以使用简单的CSS样式实现省略号控制显示. 一般的文字截断(适用于内联与块): .text-overflow{ display:block;/*内联对象 ...

  10. CTF—攻防练习之HTTP—SQl注入(get)

    攻击机:192.168.32.152 靶机 :192.168.32.157 扫描靶机扫端口: 开放了ssh和80看下ssh版本有没有漏洞,searchsplot下,没有发现 dirb扫描下目录,有个a ...