小程序三元运算

时间:2020-07-29 22:21:41   收藏:0   阅读:111
  <view tt:for="{{Arr}}">
       <image data-index="{{index}}" class="{{index===activeItemIndex?‘index-testa-img-sel‘:‘index-testa-img‘}}"
  bindtap="selectFun" src="../../image/character/danxuan{{index}}.png" mode="" />
  </view>
 
不点击时执行这个
.index-testa-img{
width:500rpx;
height:116rpx;
z-index:4;
margin-top: 12rpx;
background-color:
#fff;
}
 
点击时执行这个
.index-testa-img-sel{
width:500rpx;
height:116rpx;
z-index:5;
margin-top: 12rpx;
">#ad97ff;
}
 
data:{
activeItemIndex:100,
bgSelColor:"#fff",
Arr:["../../image/xx.png",]
},

selectFun: function(e){
this.setData({
activeItemIndex:e.target.dataset.index
})
console.log(this.data.activeItemIndex)
},

原文:https://www.cnblogs.com/Lxiaoyu/p/13399013.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!