vue中轮播图一屏幕显示多张

news/2024/7/9 23:47:51 标签: vue

1.结构

 <el-carousel arrow="always" :autoplay="false" indicator-position="none">
          <el-carousel-item v-for="(item, index) in dataList2" :key="index">
            <div class="imgl">
              <div class="imgdet" v-for="(item1, index1) in item" :key="index1" @click="huigu(item1.id)">
                <img :src="item1.cover" alt="" />
                <p class="text">{{ item1.title }}</p>
              </div>
            </div>
          </el-carousel-item>
        </el-carousel>

2.在不同屏幕显示不同的张数

 var Width = document.body.clientWidth
          console.log(Width)
          if (Width >= 1200) {
            this.dataList2 = this.formatArray(this.dataList1, 4)
          } else if (768 <= Width < 1200) {
            this.dataList2 = this.formatArray(this.dataList1, 2)
          }
          if (Width < 768) {
            console.log(Width)
            this.dataList2 = this.formatArray(this.dataList1, 1)
          }

3.函数

 formatArray(data, num) {
      var dataList2 = []
      for (var i = 0, len = data.length; i < len; i += num) {
        dataList2.push(data.slice(i, i + num))
      }
      return dataList2
    },

http://www.niftyadmin.cn/n/1512052.html

相关文章

只需两步,rails支持CSV格式导出

一、Controller最上方添加 require csv 二、方法里面添加 format.csv docsv_string CSV.generate do |csv|csv << ["Name", "Created At"]people.each do |person|csv << [person.name, person.created_at]endendrender :text > csv_strin…

Splash的爬虫应用

Splash的爬虫应用 Splash是一个JavaScript渲染服务&#xff0c;它是一个带有HTTP API的轻型Web浏览器。Python可以通过HTTP API调用Splash中的一些方法实现对页面的渲染工作&#xff0c;同时它还可以使用Lua语言实现页面的渲染&#xff0c;所以使用Splash同样可以实现动态渲染…

这是一篇博客园博文

这是一篇博客园博文。转载于:https://www.cnblogs.com/zsmynl/p/3265788.html

Python爬虫-进程间通信

Python爬虫-进程间通信 进程概述 ​ 进程&#xff08;Process&#xff09;是计算机中已运行程序的实体。进程与程序不同&#xff0c;程序本身只是指令、数据及器组织形式的描述&#xff0c;进程才是程序&#xff08;那些指令和数据&#xff09;的真正运行实体。例如在没有打开…

WCF 消息压缩性能问题及解决方法

最近使用WCF作为通迅框架开发一套信息系统,系统使用传统C/S框架,系统有可能会部署在互联网上,因此决定对传输的数据进行GZIP压缩,原来在使用.NET Remoting时,可以使用插入自定义的ChannelSink来实现数据压缩,作为.NET Remoting的替代方案的WCF,实现起来也很容易&#xff0c;且方…

vue中数组不具有响应式,需要使用vue.$set()

1.在掉完接口后在数组中的每一项添加三个属性 orderStatus(id){this.api.orderListStatus ({order_id:id}).then(res>{this.datalist res.order_detailthis.goods_info res.order_detail.goods_detailres.order_detail.goods_detail.map(item>{item[comment]item[imgL…

Python爬虫-数据处理与存储

Python爬虫-数据处理与存储 数据处理 ​ 可以使用pandas模块来实现数据处理&#xff0c;pandas是一个开源的并且通过BSD许可的库。它主要为Python语言提供高性能、易于使用数据结构和数据分析工具&#xff0c;此外还提供了多种数据操作和数据处理方法。由于pandas是第三方模块…

IOS ARC浅析

本文部分实例取自iOS 5 Toturail一书中关于ARC的教程和公开内容&#xff0c;仅用于技术交流和讨论。请不要将本文的部分或全部内容用于商用&#xff0c;谢谢合作。 欢迎转载本文&#xff0c;但是转载请注明本文出处&#xff1a;http://www.onevcat.com/2012/06/arc-hand-by-han…