Sfoglia il codice sorgente

feat: Need to handle deep objects otherwise it will return :[object Object]

赵思 2 anni fa
parent
commit
df5e1eea14
1 ha cambiato i file con 9 aggiunte e 0 eliminazioni
  1. 9 0
      src/utils/dataExporter.js

+ 9 - 0
src/utils/dataExporter.js

@@ -54,6 +54,15 @@ export default function (
     const extractObj = (obj) => {
     const extractObj = (obj) => {
       if (typeof obj !== 'object') return [obj];
       if (typeof obj !== 'object') return [obj];
 
 
+      // 需要处理深层对象 不然会返回:[object Object]
+      const kes = Object.keys(obj);
+      kes.forEach((key) => {
+        const itemValue = obj[key];
+        if (typeof itemValue === 'object') {
+          obj[key] = JSON.stringify(itemValue);
+        }
+      });
+
       return Object.values(obj);
       return Object.values(obj);
     };
     };