WXML
<!-- list,点击文字高亮,切换样式 -->
<view wx:for="{{items}}" wx:key="i" bindtap="changeColor" data-index="{{index}}" class="{{index==num?'active':''}}" >
{{index}}:{{item}}
</view>
WXSS
.active{
text-align: center;
padding: 6rpx;
color: blue;
background-color: rgb(241, 240, 227);
width: 200rpx;
height: 88rpx;
line-height: 88rpx;
margin: 0 auto;
}
JS
/**
* 点击文字高亮
*/
changeColor(e){
console.log(e.target.dataset.index);
this.setData({
num:e.target.dataset.index
});
}