🐛(component): 修复 rate 组件 modelValue 缺少响应式

This commit is contained in:
就眠儀式
2022-09-13 06:40:28 +08:00
parent 9d558c798e
commit 800aa23eff
3 changed files with 15 additions and 4 deletions

View File

@@ -5,7 +5,7 @@ export default {
</script>
<script setup lang="ts">
import { computed, ref, withDefaults } from "vue";
import { computed, ref, watch, withDefaults } from "vue";
import "./index.less";
export interface LayRateProps {
@@ -47,6 +47,10 @@ const isHalf = computed(
() => props.half && Math.round(currentValue.value) !== currentValue.value
);
watch(() => props.modelValue, () => {
currentValue.value = props.modelValue;
tempValue.value = props.modelValue;
})
// 计算评分星值
const getValue = function (index: number, event: any): number {
if (!props.half) {