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

滚动并不是使用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;
}
相关推荐
admin and root10 分钟前
AWS S3 对象存储攻防&云安全之OSS存储桶漏洞
微信小程序·小程序·渗透测试·云计算·aws·src·攻防演练
取码网24 分钟前
新版点微同城主题源码34.7+全套插件+小程序前后端 源文件
小程序
2501_9159184126 分钟前
iOS 混淆流程 提升 IPA 分析难度 实现 IPA 深度加固
android·ios·小程序·https·uni-app·iphone·webview
Ai老司机2 小时前
Notepad++ 最新版下载
notepad++·notepad·notepad 官网下载地址
布吉岛没有岛_2 小时前
小程序接入智能体
小程序·智能体
Soujer2 小时前
支持微信4.0的小程序注入调试工具(WMPFDebugger)
微信·小程序
2501_915909062 小时前
React Native 上架 App Store:项目运行与审核构建的流程
android·ios·小程序·https·uni-app·iphone·webview
路边闲人22 小时前
Notepad++插件安装,连不上网怎么办?
notepad++
李庆政3702 小时前
uniapp+unicloud打包部署微信小程序
微信小程序·小程序·uni-app
Swift社区3 小时前
鸿蒙游戏和小程序游戏的本质区别
游戏·小程序·harmonyos