Browse Source

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

* 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
ailululu 3 years ago
parent
commit
2efdc0a207
2 changed files with 16 additions and 10 deletions
  1. 9 7
      src/packages/__VUE/input/index.taro.vue
  2. 7 3
      src/packages/__VUE/input/index.vue

+ 9 - 7
src/packages/__VUE/input/index.taro.vue

@@ -329,8 +329,6 @@ export default create({
         value = value.slice(0, Number(props.maxLength));
         value = value.slice(0, Number(props.maxLength));
       }
       }
       updateValue(value);
       updateValue(value);
-      emit('update:modelValue', value, event);
-      emit('change', value, event);
     };
     };
 
 
     const updateValue = (value: string, trigger: import('./type').InputFormatTrigger = 'onChange') => {
     const updateValue = (value: string, trigger: import('./type').InputFormatTrigger = 'onChange') => {
@@ -428,16 +426,20 @@ export default create({
     watch(
     watch(
       () => props.modelValue,
       () => props.modelValue,
       () => {
       () => {
-        updateValue(getModelValue());
-        resetValidation();
+        if (!slots.input) {
+          updateValue(getModelValue());
+          resetValidation();
+        }
       }
       }
     );
     );
 
 
     onMounted(() => {
     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 {
     return {

+ 7 - 3
src/packages/__VUE/input/index.vue

@@ -425,13 +425,17 @@ export default create({
     watch(
     watch(
       () => props.modelValue,
       () => props.modelValue,
       () => {
       () => {
-        updateValue(getModelValue());
-        resetValidation();
+        if (!slots.input) {
+          updateValue(getModelValue());
+          resetValidation();
+        }
       }
       }
     );
     );
 
 
     onMounted(() => {
     onMounted(() => {
-      updateValue(getModelValue(), props.formatTrigger);
+      if (!slots.input) {
+        updateValue(getModelValue(), props.formatTrigger);
+      }
     });
     });
 
 
     return {
     return {