mirror of
https://github.com/youzan/vant.git
synced 2025-10-21 03:11:15 +00:00
[Improvement] Rate: add english document (#1010)
This commit is contained in:
@@ -1,33 +1,16 @@
|
||||
<template>
|
||||
<div :class="b()">
|
||||
<div
|
||||
<svg
|
||||
v-for="(isFull, index) in list"
|
||||
:fill="disabled ? disabledColor : isFull ? color : voidColor"
|
||||
viewBox="0 0 32 32"
|
||||
:style="style"
|
||||
:class="b('item')"
|
||||
v-for="(isFull, index) in starList"
|
||||
:key="index"
|
||||
:style="{
|
||||
'width': `${size}px`
|
||||
}"
|
||||
@click="selectRate(index)"
|
||||
@click="onSelect(index)"
|
||||
>
|
||||
<svg
|
||||
v-if="isFull"
|
||||
:fill="disabled ? defaultColor : color"
|
||||
viewBox="0 0 32 32"
|
||||
width="100%"
|
||||
height="100%"
|
||||
>
|
||||
<path d="M32 12.408l-11.056-1.607-4.944-10.018-4.944 10.018-11.056 1.607 8 7.798-1.889 11.011 9.889-5.199 9.889 5.199-1.889-11.011 8-7.798z"/>
|
||||
</svg>
|
||||
<svg
|
||||
v-else
|
||||
:fill="defaultColor"
|
||||
viewBox="0 0 32 32"
|
||||
>
|
||||
<path d="M32 12.408l-11.056-1.607-4.944-10.018-4.944 10.018-11.056 1.607 8 7.798-1.889 11.011 9.889-5.199 9.889 5.199-1.889-11.011 8-7.798zM16 23.547l-6.983 3.671 1.334-7.776-5.65-5.507 7.808-1.134 3.492-7.075 3.492 7.075 7.807 1.134-5.65 5.507 1.334 7.776-6.983-3.671z"/>
|
||||
</svg>
|
||||
</div>
|
||||
<path :d="isFull ? 'M32 12.408l-11.056-1.607-4.944-10.018-4.944 10.018-11.056 1.607 8 7.798-1.889 11.011 9.889-5.199 9.889 5.199-1.889-11.011 8-7.798z' : 'M32 12.408l-11.056-1.607-4.944-10.018-4.944 10.018-11.056 1.607 8 7.798-1.889 11.011 9.889-5.199 9.889 5.199-1.889-11.011 8-7.798zM16 23.547l-6.983 3.671 1.334-7.776-5.65-5.507 7.808-1.134 3.492-7.075 3.492 7.075 7.807 1.134-5.65 5.507 1.334 7.776-6.983-3.671z'" />
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -49,7 +32,7 @@ export default create({
|
||||
type: String,
|
||||
default: '#ffd21e'
|
||||
},
|
||||
defaultColor: {
|
||||
voidColor: {
|
||||
type: String,
|
||||
default: '#c7c7c7'
|
||||
},
|
||||
@@ -57,7 +40,7 @@ export default create({
|
||||
type: String,
|
||||
default: '#bdbdbd'
|
||||
},
|
||||
total: {
|
||||
count: {
|
||||
type: Number,
|
||||
default: 5
|
||||
},
|
||||
@@ -68,13 +51,19 @@ export default create({
|
||||
},
|
||||
|
||||
computed: {
|
||||
starList() {
|
||||
return new Array(this.total).fill(false).map((value, index) => index < this.value);
|
||||
style() {
|
||||
return {
|
||||
width: this.size + 'px'
|
||||
};
|
||||
},
|
||||
|
||||
list() {
|
||||
return new Array(this.count).fill(false).map((value, index) => index < this.value);
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
selectRate(index) {
|
||||
onSelect(index) {
|
||||
if (!this.disabled) {
|
||||
this.$emit('input', index + 1);
|
||||
}
|
||||
|
Reference in New Issue
Block a user