(H5轮播)vue一个轮播里显示多个内容/一屏展示两个半内容

效果图 :

html:

  <div class="content">
          <van-swipe
            class="my-swipe com-long-swipe-indicator"
            :autoplay="2500"
            indicator-color="#00C4FF"
          >
            <van-swipe-item
              class="flex-row-wrap"
              v-for="(items, index) in Math.ceil(conferenceData.length / 9)"
              :key="`guests_${index}`"
            >
              <div
                v-for="(item, index) in conferenceData.slice(
                  (items - 1) * 9,
                  items * 9
                )"
                :key="index"
                class="conference-guests-item-box"
              >
                <div
                  class="conference-guests-item-img flex-column-start-end"
                  :style="{ background: 'url(' + item.picture + ')' }"
                >
                  <div class="conference-guests-item-text">
                    <div class="conference-guests-item-name">
                      {{ item.name }}
                    </div>
                    <div class="conference-guests-item-company">
                      {{ item.company }}
                    </div>
                    <div class="conference-guests-item-profession">
                      {{ item.profession }}
                    </div>
                  </div>
                </div>
              </div>
            </van-swipe-item>
          </van-swipe>
        </div>

return里声明的数据或者直接使用后台返回的数据

 conferenceData: [
        {
          company: "科技公司",
          name: "张三",
          pawId: "3760726639167201673",
          picture:
            "../digital_system/cbc8a90f3a6a4e699646a0d45f89a001.jpg",
          profession: "执行董事/董事长兼首席执行官",
          sort: 0,
          webGuestId: "3775644503695286273",
        },
        {
          company: "科技公司",
          name: "张三",
          pawId: "3760726639167201673",
          picture:
            "../digital_system/cbc8a90f3a6a4e699646a0d45f89a001.jpg",
          profession: "执行董事/董事长兼首席执行官",
          sort: 1,
          webGuestId: "3775644503695286273",
        },
        {
          company: "科技公司",
          name: "张三",
          pawId: "3760726639167201673",
          picture:
            "../digital_system/cbc8a90f3a6a4e699646a0d45f89a001.jpg",
          profession: "执行董事/董事长兼首席执行官",
          sort: 2,
          webGuestId: "3775644503695286273",
        },
        {
          company: "科技公司",
          name: "张三",
          pawId: "3760726639167201673",
          picture:
            "../digital_system/cbc8a90f3a6a4e699646a0d45f89a001.jpg",
          profession: "执行董事/董事长兼首席执行官",
          sort: 3,
          webGuestId: "3775644503695286273",
        },
        {
          company: "科技公司",
          name: "张三",
          pawId: "3760726639167201673",
          picture:
            "../digital_system/cbc8a90f3a6a4e699646a0d45f89a001.jpg",
          profession: "执行董事/董事长兼首席执行官",
          sort: 4,
          webGuestId: "3775644503695286273",
        },
        {
          company: "科技公司",
          name: "张三",
          pawId: "3760726639167201673",
          picture:
            "../digital_system/cbc8a90f3a6a4e699646a0d45f89a001.jpg",
          profession: "执行董事/董事长兼首席执行官",
          sort: 5,
          webGuestId: "3775644503695286273",
        },
        {
          company: "科技公司",
          name: "张三",
          pawId: "3760726639167201673",
          picture:
            "../digital_system/cbc8a90f3a6a4e699646a0d45f89a001.jpg",
          profession: "执行董事/董事长兼首席执行官",
          sort: 6,
          webGuestId: "3775644503695286273",
        },
        {
          company: "科技公司",
          name: "张三",
          pawId: "3760726639167201673",
          picture:
            "../digital_system/cbc8a90f3a6a4e699646a0d45f89a001.jpg",
          profession: "执行董事/董事长兼首席执行官",
          sort: 7,
          webGuestId: "3775644503695286273",
        },
        {
          company: "科技公司",
          name: "张三",
          pawId: "3760726639167201673",
          picture:
            "../digital_system/cbc8a90f3a6a4e699646a0d45f89a001.jpg",
          profession: "执行董事/董事长兼首席执行官",
          sort: 8,
          webGuestId: "3775644503695286273",
        },
        {
          company: "科技公司",
          name: "张三",
          pawId: "3760726639167201673",
          picture:
            "../digital_system/cbc8a90f3a6a4e699646a0d45f89a001.jpg",
          profession: "执行董事/董事长兼首席执行官",
          sort: 9,
          webGuestId: "3775644503695286273",
        },
        {
          company: "科技公司",
          name: "张三",
          pawId: "3760726639167201673",
          picture:
            "../digital_system/cbc8a90f3a6a4e699646a0d45f89a001.jpg",
          profession: "执行董事/董事长兼首席执行官",
          sort: 10,
          webGuestId: "3775644503695286273",
        },
      ], //嘉宾数据

css:

.flex-row-wrap {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
}
.flex-column-start-end {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
}
.conference-guests-item-box {
    flex: 0 0 33.33%;
  }
  .conference-guests-item-img {
    width: 100%;
    height: 2.28rem;
    background-size: 100% !important;
  }
  .conference-guests-item-text {
    padding: 0 0 0.06rem 0.2rem;
    font-size: 0.12rem;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: #ffffff;
    line-height: 0.16rem;
  }
  .conference-guests-item-name {
    font-size: 0.16rem;
    font-family: SourceHanSansCN-Heavy, SourceHanSansCN;
    font-weight: 800;
    color: #ffffff;
    line-height: 0.23rem;
    margin-bottom: 0.08rem;
  }

效果图:

html:

cnLeftItem:[]为后台返回数据

      <van-swipe
              class="com-long-swipe-indicator"
              :loop="false"
              :width="swipeWidth"
            >
              <van-swipe-item v-for="item in cnLeftItem" :key="item.webNewsId">
                <a
                  :href="item.jumpLink || 'javascript:;'"
                  target="_blank"
                  class="report-item default-bg"
                  :style="{
                    'background-image': `url(${item.cover})`,
                  }"
                >
                  <span class="report-item-news-title van-multi-ellipsis--l2">
                    {{ item.newsTitle }}
                  </span>
                </a></van-swipe-item
              >
            </van-swipe>

js:

  created() {
    //一定要写在created里,在数据渲染完成之前拿到屏幕宽度
    this.bodyWidth = window.innerWidth;
    this.swipeWidth = window.innerWidth * 0.3946;
  },
相关推荐
长风清留扬19 分钟前
小程序毕业设计-音乐播放器+源码(可播放)下载即用
javascript·小程序·毕业设计·课程设计·毕设·音乐播放器
web1478621072332 分钟前
C# .Net Web 路由相关配置
前端·c#·.net
m0_7482478033 分钟前
Flutter Intl包使用指南:实现国际化和本地化
前端·javascript·flutter
飞的肖37 分钟前
前端使用 Element Plus架构vue3.0实现图片拖拉拽,后等比压缩,上传到Spring Boot后端
前端·spring boot·架构
青灯文案144 分钟前
前端 HTTP 请求由 Nginx 反向代理和 API 网关到后端服务的流程
前端·nginx·http
m0_748254881 小时前
DataX3.0+DataX-Web部署分布式可视化ETL系统
前端·分布式·etl
ZJ_.1 小时前
WPSJS:让 WPS 办公与 JavaScript 完美联动
开发语言·前端·javascript·vscode·ecmascript·wps
GIS开发特训营1 小时前
Vue零基础教程|从前端框架到GIS开发系列课程(七)响应式系统介绍
前端·vue.js·前端框架·gis开发·webgis·三维gis
Cachel wood2 小时前
python round四舍五入和decimal库精确四舍五入
java·linux·前端·数据库·vue.js·python·前端框架
学代码的小前端2 小时前
0基础学前端-----CSS DAY9
前端·css