封装一个星级打分的组件
<template>
<div>
<div
v-for="index in maxValue"
:key="index"
class="iconfont icon-star star-item star-placeholder"
>
<div
class="iconfont icon-star star-item star-active"
:style="{ width: getWidth(index), color: activeColor }"
/>
</div>
<span class="star-value">
{
{ starValue }}
</span>
</div>
</template>
<script>
import '@/assets/css//icon-star.css'
export default {
name: 'starLevel',
props: {
maxValue: {
type: Number,
default: 5
},
value: {
type: Number,
default: 4.5
},
activeColor: {
type: String,
default: '#ff7e28'
}
},
computed: {
starValue () {
return this.value.toFixed(1)
}
},
methods: {
getW