vue uniapp 小程序 v-for遍历,点击某一项,动态改变样式
<view class="content"><view :class="index==colin?'c-contents':'c-content'" v-for="(item, index) in hswt" :key="item.id" @tap="dhsaa":data-msgs="item"><text :class="index==colin?'c-conte
·
<view class="content">
<view :class="index==colin?'c-contents':'c-content'" v-for="(item, index) in hswt" :key="item.id" @tap="dhsaa":data-msgs="item">
<text :class="index==colin?'c-content2':'c-content1'" >{{item.value}}</text>
</view>
<view class="confrim-btn" >
进入投放
</view>
</view>
export default {
data() {
return {
colin:0, //选中的某项
item: {}, //柜子的信息
munber: 6, //柜子数量
show: false, //弹框
hswt: [{
id: 1,
value: '一件套'
},
{
id: 2,
value: '四件套'
},
{
id: 3,
value: '六件套'
}
]
}
},
}
dhsaa(e) {
let item = e.currentTarget.dataset.msgs
console.log(item, 'item')
this.colin = item.id-1
},
.content {
width: 640rpx;
height: 460rpx;
background: #F6F6F6;
border-radius: 14rpx;
display: flex;
/* justify-content: center; */
flex-direction: column;
align-items: center;
align-self: center;
}
.c-contents {
display: flex;
align-items: center;
align-self: center;
justify-content: center;
flex-direction: column;
width: 500rpx;
height: 80rpx;
border: 1rpx solid #46C1D5;
background: #EFEFEF;
border-radius: 12rpx;
margin-top: 20rpx;
}
.c-content {
display: flex;
align-items: center;
align-self: center;
justify-content: center;
flex-direction: column;
width: 500rpx;
height: 80rpx;
background: #EFEFEF;
border-radius: 12rpx;
margin-top: 20rpx;
}
.c-content1 {
display: flex;
justify-content: center;
align-items: center;
font-size: 28rpx;
font-family: PingFang SC;
font-weight: 500;
color: #5D5F5B;
}
.c-content2 {
display: flex;
justify-content: center;
align-items: center;
font-size: 28rpx;
font-family: PingFang SC;
font-weight: 500;
color: #46C1D5;
}
更多推荐
已为社区贡献4条内容
所有评论(0)