Skip to content

Commit

Permalink
修复taro中input@update:model-value事件会触发两次 #1632 (#1790)
Browse files Browse the repository at this point in the history
* feat: 发票组件+taro

* feat: 发票组件+taro

* fix: #1450将placeholder默认为空

* fix: 解决发票 radio类型的问题

* fix: navbar修改leftShow默认值

* fix: #1521navbar解决定不安全区域问题

* fix: 修改input taro demo文案

* fix: 修复taro中input@update:model-value事件会触发两次 #1632

* fix: 修复input组件的slot=input插槽报错,卡住页面 #1776
  • Loading branch information
ailululu authored Nov 2, 2022
1 parent 5f96976 commit 2efdc0a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
16 changes: 9 additions & 7 deletions src/packages/__VUE/input/index.taro.vue
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,6 @@ export default create({
value = value.slice(0, Number(props.maxLength));
}
updateValue(value);
emit('update:modelValue', value, event);
emit('change', value, event);
};
const updateValue = (value: string, trigger: import('./type').InputFormatTrigger = 'onChange') => {
Expand Down Expand Up @@ -428,16 +426,20 @@ export default create({
watch(
() => props.modelValue,
() => {
updateValue(getModelValue());
resetValidation();
if (!slots.input) {
updateValue(getModelValue());
resetValidation();
}
}
);
onMounted(() => {
if (props.autofocus) {
inputRef.value.focus();
if (!slots.input) {
if (props.autofocus) {
inputRef.value.focus();
}
updateValue(getModelValue(), props.formatTrigger);
}
updateValue(getModelValue(), props.formatTrigger);
});
return {
Expand Down
10 changes: 7 additions & 3 deletions src/packages/__VUE/input/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -425,13 +425,17 @@ export default create({
watch(
() => props.modelValue,
() => {
updateValue(getModelValue());
resetValidation();
if (!slots.input) {
updateValue(getModelValue());
resetValidation();
}
}
);
onMounted(() => {
updateValue(getModelValue(), props.formatTrigger);
if (!slots.input) {
updateValue(getModelValue(), props.formatTrigger);
}
});
return {
Expand Down

0 comments on commit 2efdc0a

Please sign in to comment.