fix(rate): fix bugs,allow-half not correct #546

This commit is contained in:
liuxs 2020-11-05 13:13:03 +08:00 committed by hangzou
parent ee744e2925
commit 246a12b466
2 changed files with 23 additions and 3 deletions

View File

@ -192,9 +192,9 @@ export default defineComponent({
const classes = computed(() => { const classes = computed(() => {
let result = Array(props.max) let result = Array(props.max)
let threshold = currentValue.value let threshold = currentValue.value
if (props.allowHalf && currentValue.value !== Math.floor(currentValue.value)) { // if (props.allowHalf && currentValue.value !== Math.floor(currentValue.value)) {
threshold-- // threshold--
} // }
result.fill(activeClass.value, 0, threshold) result.fill(activeClass.value, 0, threshold)
result.fill(voidClass.value, threshold, props.max) result.fill(voidClass.value, threshold, props.max)
return result return result

View File

@ -32,6 +32,26 @@
``` ```
::: :::
### 允许半选
:::demo 为组件设置 `allow-half` 允许出现半星
```html
<div class="block">
<el-rate v-model="value" allow-half />
</div>
<script>
export default {
data() {
return {
value: null
}
}
}
</script>
```
:::
### 辅助文字 ### 辅助文字
用辅助文字直接地表达对应分数 用辅助文字直接地表达对应分数