<el-rate> 評(píng)分自定義圖

自定義圖片

image.png

根據(jù)選中的多少,展示不同的圖片

image.png
<template>
     <el-rate
        v-model="rateValue1"
        :icon-classes="['custom-icon-1', 'custom-icon-2', 'custom-icon-3']"
        void-icon-class="custom-icon-void"
      >
      </el-rate>

      <el-rate
        v-model="rateValue2"
        show-text
        :texts="['很差', '較差', '一般', '不錯(cuò)', '很棒']"
        :icons="[
          'el-icon-frown',
          'el-icon-frown',
          'el-icon-meh',
          'el-icon-smile',
          'el-icon-star-on',
        ]"
        :colors="['#99A9BF', '#F7BA2A', '#FF9900', 'red', 'purple']"
      ></el-rate>

      <el-rate
        v-model="rateValue3"
        :texts="['很差', '較差', '一般', '不錯(cuò)', '很棒']"
        show-text
      ></el-rate>

      <el-rate v-model="rateValue4" :max="6">
        <template #default="{ index }">
          {{ ["很差", "差", "一般", "好", "很好", "極好"][index] }}
        </template>
      </el-rate>
    </div>
</template>
 data() {
    return {
      rateValue1: 2,
      rateValue2: 4,
      rateValue3: 2,
      rateValue4: 5,
      customIcons: [
        "el-icon-circle-close",
        "el-icon-minus",
        "el-icon-circle-check",
      ],
      iconClasses: ["icon-rate-face-1", "icon-rate-face-2", "icon-rate-face-3"],
      texts: ["很垃圾", "垃圾", "還行", "漂亮", "五星好評(píng)"],
}
}
<style scoped>

::v-deep .custom-icon-1 {
  background: url("url");
  background-size: cover;
  width: 20px;
  height: 20px;
  display: inline-block;
}

::v-deep .custom-icon-2 {
  background: url("url");
  background-size: cover;
  width: 20px;
  height: 20px;
  display: inline-block;
}

::v-deep .custom-icon-3 {
  background: url("url");
  background-size: cover;
  width: 20px;
  height: 20px;
  display: inline-block;
}

::v-deep .custom-icon-void {
  background: url("url");
  background-size: cover;
  width: 20px;
  height: 20px;
  display: inline-block;
  opacity: 0.5;
}
</style>
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容