Skip to content

Commit b12b7f8

Browse files
committed
fix: rate not update #4294
close #4294
1 parent 891f6db commit b12b7f8

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

components/rate/index.tsx

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ExtractPropTypes, VNode } from 'vue';
1+
import { ExtractPropTypes, VNode, watch } from 'vue';
22
import { defineComponent, ref, reactive, onMounted } from 'vue';
33
import { initDefaultProps, getPropsSlot, findDOMNode } from '../_util/props-util';
44
import { withInstall } from '../_util/type';
@@ -53,7 +53,12 @@ const Rate = defineComponent({
5353
cleanedValue: null,
5454
hoverValue: undefined,
5555
});
56-
56+
watch(
57+
() => props.value,
58+
() => {
59+
state.value = props.value;
60+
},
61+
);
5762
const getStarDOM = (index: number) => {
5863
return findDOMNode(starRefs.value[index]);
5964
};
@@ -73,7 +78,9 @@ const Rate = defineComponent({
7378
return value;
7479
};
7580
const changeValue = (value: number) => {
76-
state.value = value;
81+
if (props.value === undefined) {
82+
state.value = value;
83+
}
7784
emit('update:value', value);
7885
emit('change', value);
7986
};

0 commit comments

Comments
 (0)