微信小程序卡片横向滚动竖图

滚动并不是使用swiper,该方式使用的是scroll-view实现

Swiper局限性太多了,对竖图并不合适

从左往右滚动图片示例

wxml代码:

html 复制代码
<view class="img-x" style="margin-top: 10px;">
            <view style="margin: 20rpx;font-family: auto;font-weight: bold;font-size: medium;">最新内容 ></view>
            <scroll-view scroll-x >
                <view style="display: flex;flex-direction: row;">
                  <block wx:for="{{background}}" wx:key="*this">
                      <view wx:if="{{index!=0&&index!=(background.length-1)}}" style="margin-left: 10rpx;margin-right: 10rpx;">
                          <image mode="aspectFill" class="img-x-v" src="{{item}}"></image>
                      </view>
                      <view wx:if="{{index==0}}" style="margin-right: 5rpx;">
                          <image mode="aspectFill" class="img-x-v" src="{{item}}"></image>
                      </view>
                      <view wx:if="{{index==(background.length-1)}}" style="margin-left: 5rpx;">
                          <image mode="aspectFill" class="img-x-v" src="{{item}}"></image>
                      </view>
                  </block>
                </view>
            </scroll-view>
          </view>

js代码:

html 复制代码
Page({
   data: {
      background: ['图片地址1','图片地址2','图片地址3']
   }
})

wxss代码:

html 复制代码
.img-x{
  z-index: 100;
}
.img-x-v{
  width: 300rpx;
  border-radius: 18rpx;
  height: 550rpx;
}
相关推荐
mon_star°2 小时前
微信答题小程序支持latex公式显示解决方案
微信·小程序
MaCa .BaKa15 小时前
38-日语学习小程序
java·vue.js·spring boot·学习·mysql·小程序·maven
HouGISer15 小时前
副业小程序YUERGS,从开发到变现
前端·小程序
橘子海全栈攻城狮17 小时前
【源码+文档+调试讲解】党员之家服务系统小程序1
java·开发语言·spring boot·后端·小程序·旅游
好好的哦18 小时前
uni-app小程序登录后…
小程序·uni-app
h_65432101 天前
微信小程序点击按钮跳转链接并显示
微信小程序·小程序
银迢迢1 天前
微信小程序的开发及问题解决
微信小程序·小程序
liyinchi19881 天前
原生微信小程序 textarea组件placeholder无法换行的问题解决办法
微信小程序·小程序
说私域2 天前
基于开源链动2+1模式AI智能名片S2B2C商城小程序的低集中度市场运营策略研究
人工智能·小程序·开源·零售
少恭写代码2 天前
duxapp 2025-03-29 更新 编译结束的复制逻辑等
react native·小程序·taro