chore: array fill (#8263)

This commit is contained in:
neverland
2021-03-04 14:04:47 +08:00
committed by GitHub
parent 12be46fad8
commit 3fd2972b7c
6 changed files with 19 additions and 36 deletions
+5 -7
View File
@@ -73,13 +73,11 @@ export default createComponent({
const untouchable = () =>
props.readonly || props.disabled || !props.touchable;
const list = computed(() => {
const list: RateStatus[] = [];
for (let i = 1; i <= props.count; i++) {
list.push(getRateStatus(props.modelValue, i, props.allowHalf));
}
return list;
});
const list = computed<RateStatus[]>(() =>
Array(props.count)
.fill('')
.map((_, i) => getRateStatus(props.modelValue, i + 1, props.allowHalf))
);
const select = (index: number) => {
if (!props.disabled && !props.readonly && index !== props.modelValue) {