Эх сурвалжийг харах

优化参照版本1中清空绑定值,清空对应的dataMapping

002390 1 жил өмнө
parent
commit
f24af15423

+ 18 - 5
src/components/popover-select/index.vue

@@ -125,6 +125,19 @@ export default {
       },
       immediate: true,
     },
+    innerValue: {
+      handler: function (newValue) {
+        if (!newValue) {
+          const {
+            $props: { source, dataMapping },
+          } = this;
+          for (let key in dataMapping) {
+            source[key] = undefined;
+          }
+          this.$emit("update:source", source);
+        }
+      },
+    },
   },
   methods: {
     //
@@ -256,11 +269,11 @@ export default {
     handleClear() {
       const { source, multiple, dataMapping } = this.$props;
       if (!multiple) {
-        // this.innerValue = "";
-        for (let key in dataMapping) {
-          source[key] = "";
-        }
-        this.$emit("update:source", source);
+        this.innerValue = "";
+        // for (let key in dataMapping) {
+        //   source[key] = "";
+        // }
+        // this.$emit("update:source", source);
       }
     },
     async useAutocomplete(prop, cb) {