本文主要是介绍微信小程序卡片横向滚动竖图,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
进入下面小程序可以体验效果:
滚动并不是使用swiper,该方式使用的是scroll-view实现
Swiper局限性太多了,对竖图并不合适
从左往右滚动图片示例
wxml代码:
<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代码:
Page({data: {background: ['图片地址1','图片地址2','图片地址3']}
})
wxss代码:
.img-x{z-index: 100;
}
.img-x-v{width: 300rpx;border-radius: 18rpx;height: 550rpx;
}
这篇关于微信小程序卡片横向滚动竖图的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!