如图,,点击选中,选中的框变色,其他不变,可以来回切换
发布于 6 年前 作者 pingliao 2957 次浏览 来自 问答

请问怎么实现?求大神赐教,最好有demo,在线等,急用

7 回复

点击事件的index,用index来控制选中的样式

<block wx:for="{{house.imgs}}" wx:key="{{index}}">

<image class="{{item == selectImg?’’:‘noselect’}}" style=“width:145rpx;height:94rpx;” mode=“aspectFill” bindtap=“selectImg” id="{{index}}" src="{{item}}"/>

</block>

// 选择图片显示

selectImg:function(e){

var that = this,

imgId = e.currentTarget.id

that.setData({

selectImg: that.data.house.imgs[imgId],

selectVideo:""

})

},

changeColor:that.data.mblist[i].name

item.name == changeColor

样式写了,不知道咋切换?用三目运算符,一直没效果,请问具体怎么做?

写两个样式,一个是红色边框,一个无边框,动态切换样式就行了

请问是在wxml里面判断,还是在js里判断?有代码吗,粘出来看看,谢谢!

哪位知道,请告知一下

回到顶部