vue 文字點擊變色


樣式圖:

 

 

html:

 <div :key="index" v-for="(item, index) in standing" class="Category">
      <label
        class="Planning"
        v-bind:class="{ updata_clable: IsIndex === index }"
        @click="change(index)"
        >{{ item.name }}</label
      >
    </div>

js:

<script>
export default {
  data() {
    return {
      standing: [
        { name: "李現" },
        { name: "鄧倫" },
        { name: "王俊凱" },
        { name: "千璽" }
      ],
      IsIndex: 0
    };
  },
  methods: {
    change: function(index) {
      this.IsIndex = index;
    }
  }
};
</script>

css:

.Planning {
  font-size: 14px;
  font-family: DengXian;
  font-weight: bold;
  line-height: 14px;
  color: rgba(112, 112, 112, 1);
  opacity: 1;
  display: block;
  text-align: center;
}
.Category {
  width: 100%;
  height: 40px;
  margin-top: 10px;
}
.updata_clable {
  color: #19874f;
}

v-bind就是用於綁定數據和元素屬性的


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM