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

在岁月中跋涉,每个人都有自己的故事,看淡心境才会秀丽,看开心情才会明媚。累时歇一歇,随清风漫舞,烦时静一静,与花草凝眸,急时缓一缓,和自己微笑。

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

图片左右滑动效果图:


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> 

到此这篇关于微信小程序图片横向左右滑动案例就介绍到这了。人为善,福虽未至,祸已远离;人为恶,祸虽未至,福已远离。更多相关微信小程序图片横向左右滑动案例内容请查看相关栏目,小编编辑不易,再次感谢大家的支持!

标签: 小程序