fix(rate) 修复组件Rate半选加禁选后,2.5与3星实际不匹配的问题 (#200)

This commit is contained in:
wwttff 2023-05-12 20:43:55 -07:00 committed by GitHub
parent 437d1e6177
commit 50723613fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -1,5 +1,5 @@
<template>
<tiny-rate v-model="rate" disabled></tiny-rate>
<tiny-rate v-model="rate" allow-half disabled></tiny-rate>
</template>
<script lang="jsx">
@ -11,7 +11,7 @@ export default {
},
data() {
return {
rate: 3
rate: 2.5
}
}
}

View File

@ -201,7 +201,10 @@ export const computedDecimalStyle = ({ props, state }) => {
if (props.disabled) {
width = `${props.modelValue * 100 - Math.floor(props.modelValue) * 100 < 50 ? 0 : 100}%`
} else if (props.allowHalf) {
}
if (props.allowHalf) {
width = ''
const reactSize = props.size ? Math.ceil(parseInt(props.size) / 2) + 'px' : '6px'
clip = `rect(0px, ${reactSize}, ${props.size || '14px'}, 0px)`