微信小程序,无法实现点击左边,字体和背景变色

Page({

data: {

activeId:2,

typelist:[

{

id:1,

title:"家具"}, {

id:2,

title: "家具"}, {

id:3,

title: "家具"}, {

id:4,

title: "家具" }, {

id:5,

title: "家具"

}

]

},

onLoad: function (options) {

},

selectType(e){

this.setData({

activeId: e.currentTarget.dataset.id

})

}

})

————————————

wxml

<view class="contAIner">

<view class="left">

 

<view  wx:for="{{typelist}}" class="{{itme.id==activeId?'active':''}}"

bindtap="selectType" data-Id="{{item.id}}">

{{item.title}}

</view></view>

 

<view class="right"></view>

</view>

———————————–

wxss

.left{

width: 250rpx;

background: #eee;

height: 1000rpx;

}

 

.left view{

padding: 10px 0px;

text-align: center;

}

.left view.active{

color: burlywood;

background: #fff;

}

.right{

flex: 1;

}

.comtainer{

display: flex;

min-height: 100vh;

}

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容