Skip to content

Commit

Permalink
chore: pref code
Browse files Browse the repository at this point in the history
  • Loading branch information
PengYYYYY committed May 13, 2022
1 parent 296e831 commit c0edc36
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
11 changes: 4 additions & 7 deletions src/hooks/useDefaultValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,10 @@ export default function useDefaultValue<T, P extends any[]>(
internalValue.value = value.value;
}

// 监听value与modelValue的变化
watch(
() => value.value,
(newVal) => {
internalValue.value = newVal;
},
);
// 监听value变化
watch(value, (newVal) => {
internalValue.value = newVal;
});

// 非受控模式
return [
Expand Down
18 changes: 6 additions & 12 deletions src/hooks/useVModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,12 @@ export default function useVModel<T, P extends any[]>(
}

// 监听value与modelValue的变化
watch(
() => value.value,
(newVal) => {
internalValue.value = newVal;
},
);
watch(
() => modelValue.value,
(newVal) => {
internalValue.value = newVal;
},
);
watch(value, (newVal) => {
internalValue.value = newVal;
});
watch(modelValue, (newVal) => {
internalValue.value = newVal;
});

return [
internalValue,
Expand Down

0 comments on commit c0edc36

Please sign in to comment.