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-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;
    }
  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值