欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

微信小程序图片横向左右滑动案例

程序员文章站 2022-06-12 23:16:06
本文实例为大家分享了微信小程序图片左右滑动的具体代码,供大家参考,具体内容如下 图片左右滑动效果图: wxml代码:

本文实例为大家分享了微信小程序图片左右滑动的具体代码,供大家参考,具体内容如下

图片左右滑动效果图:

微信小程序图片横向左右滑动案例

wxml代码:

<scroll-view scroll-x="true"> 
<view class="uploadwrap" scroll-x="true"> 
 <view class="upload_item"> 
  <image class="upload_item_img" src="../../image/test1.jpg"></image> 
 </view> 
 <view class="upload_item"> 
  <image class="upload_item_img" src="../../image/test2.jpg"></image> 
 </view> 
 <view class="upload_item"> 
  <image class="upload_item_img" src="../../image/test3.jpg"></image> 
 </view> 
 <view class="upload_item"> 
  <image class="upload_item_img" src="../../image/test4.jpg"></image> 
 </view> 
 <view class="upload_item"> 
  <image class="upload_item_img" src="../../image/test1.jpg"></image> 
 </view> 
 <view class="upload_item"> 
  <image class="upload_item_img" src="../../image/test2.jpg"></image> 
 </view> 
 <view class="upload_item"> 
  <image class="upload_item_img" src="../../image/test3.jpg"></image> 
 </view> 
 
</view> 
</scroll-view> 

wxss代码:

.uploadwrap{height:160rpx; width:100%; display: flex; display: -webkit-box; flex-direction: column;} 
.upload_item{ width: 160rpx; height: 160rpx; flex: 1;} 
.upload_item_img{ width: 160rpx; height: 160rpx;} 

wxml从后台获取数据代码:

<scroll-view scroll-x="true"> 
 <view class="uploadwrap" scroll-x="true" > 
  <view class="upload_item" wx:for="{{imgurls}}" wx:key="id"> 
   <image class="upload_item_img" src="{{item.imgurl}}"data-id="{{item.id}}" bindtap="changemainimgfn2"></image> 
   <icon type="clear" size="16" class="upload_btn" color="#f64400"></icon> 
   <view class="upload_mask {{upload_imgselid2==item.id? 'show':' ' }}">主图</view> 
  </view> 
 </view> 
</scroll-view> 

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。