vant 选中标签变色(单选)

需要样式效果

实现

<div class="tags" v-for="item in cityList"
 :key="item.id">
   <van-tag round
 type="primary"
 color="#F4F5F7"
 text-color="#606060"
 size="large"
 @click="clickTag(item.id)"
 :class="tagColor === item.id?'tag-click':''"
 > {{ `\xa0\xa0${item.name}\xa0\xa0`}} </van-tag>
 </div>

methods: {
   
    clickTag (id) {
      if (id) {
        this.tagColor = id
      }
    },
  }
 data () {
    return {
      tagColor: 0,
    }
  },
<style scoped lang="less">
.tag-click{
  border: 0.02667rem solid #1E90FF !important;
  color:#1E90FF !important
}
</style>

posted @ 2022-06-24 15:17  小杨爱学习!  阅读(668)  评论(0编辑  收藏  举报