小程序循环点击某个使用js更改css样式
作者:互联网
//wxml <block wx:for="{{Listsimg}}" wx:key='unique'> <block wx:if="{{index == clickId}}"> <view class="img" style="border:{{border}};box-shadow:{{borders}}" id="{{index}}" bindtap="imgList" data-data="{{item}}"> <image src="{{item.imgList}}" /> </view> </block> <block wx:else> <view class="img" id="{{index}}" bindtap="imgList" data-data="{{item}}"> <image src="{{item.imgList}}" /> </view> </block> </block> //js data: { Listsumg: [ { imgList: '../../images/1.jpg' }, { imgList: '../../images/2.jpg' }, { imgList: '../../images/3.jpg' } ], border:'', clickId:'', borders:'' }, imgList:function(e){ console.log(this.data.imgLists[e.currentTarget.id]) this.setData({ border:"1rpx solid #eee", borders:'10rpx 10rpx 10rpx rgba(141, 161, 167, 0.9);', clickId:e.currentTarget.id }) },
标签:..,imgList,jpg,js,点击,10rpx,images,border,css 来源: https://www.cnblogs.com/minghan/p/13266417.html