datav 轮播表

在这里插入图片描述
 

<template>
  <div>
    <dv-scroll-board :config="config" style="margin-left:1rem;width:95%;height:48rem" />
  </div>
</template>

 

<script>
export default {
  props:['AreaData'],
  data(){
    return {
      config:{
        header: ['地区编码','地区名称','订单数量'],
        indexHeader:'序号',
        rowNum: 23, // 表行数
        headerBGC: '#eb5a6d', // 表头背景色
        oddRowBGC: '#FFF', // 奇数行背景色
        evenRowBGC: '#f5f5f5', // 偶数行背景色
        waitTime: 2000, // 轮播时间间隔(ms)
        align: ['center'],
        data: []
      }
    }
  },
  watch:{
    AreaData(val){
      console.log(val)
      let arr = []
      if(val.length >0){
        for(let i in val){
          let code = val[i].area
          let name = val[i].name
          let num = val[i].num
          arr.push([code,name, `<div style="background:#67e0e3; white-space:nowrap; width:${num/1000}px !important">${num}</div>`])
        }
        let nowData = this.config
        nowData.data = arr
        this.config = {...nowData}
      }
    }
  }
}
</script>
<style lang="less" scoped>
  .dv-scroll-board{
    color:#333;
    /deep/ .header-item{
      font-size: 1em;
      text-align: center;
      white-space: nowrap;
      color:#FFF !important;
    }
    .rows{
      .row-item{
        text-align: center;
        line-height: 2rem;
        .ceil{
          color:#3c3f52;
          font-size: 1em;
          i{
            font-size: 0.5em;
          }
        }
        .ceil:nth-child(2){
          color: #eb5a6d !important;
          font-size: 1.1em;
          width: 25%;
        }
      }
    }
  }
  .test{
    width: 10px;
    background-size: 10% 10%;
    word-break:keep-all;/* 不换行 */
    white-space:nowrap;/* 不换行 */
     background: #eb5a6d;
  }
</style>
  • 4
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
可以使用Vue中的`v-for`、`v-bind`、`v-on`等指令来实现自动轮播。以下是一个基本的示例代码: ```html <template> <div class="carousel"> <div class="carousel-wrapper" :style="{transform: 'translateX(' + translateX + 'px)'}"> <div class="carousel-item" v-for="(item, index) in items" :key="index"> <img :src="item.image" alt=""> <p>{{ item.title }}</p> </div> </div> </div> </template> <script> export default { data() { return { items: [ {image: 'image1.jpg', title: 'Image 1'}, {image: 'image2.jpg', title: 'Image 2'}, {image: 'image3.jpg', title: 'Image 3'}, {image: 'image4.jpg', title: 'Image 4'} ], currentIndex: 0, translateX: 0, timer: null } }, mounted() { this.startAutoPlay() }, methods: { startAutoPlay() { this.timer = setInterval(() => { this.handleNext() }, 3000) }, handleNext() { this.currentIndex = (this.currentIndex + 1) % this.items.length this.translateX = -this.currentIndex * 100 } }, beforeDestroy() { clearInterval(this.timer) } } </script> <style scoped> .carousel { width: 100%; overflow: hidden; } .carousel-wrapper { display: flex; transition: transform 0.5s ease-in-out; } .carousel-item { width: 100%; flex-shrink: 0; text-align: center; } </style> ``` 在上面的代码中,我们使用`v-for`指令循环渲染数据,并使用`v-bind`将数据动态绑定到`style`属性上,从而实现图片的滑动效果。我们还使用了`v-on`指令监听定时器事件,实现自动轮播功能。最后,在组件销毁前清除定时器,避免内存泄露。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值