Ver Fonte

1.代码维护

spy há 1 mês atrás
pai
commit
46bf5af776
1 ficheiros alterados com 85 adições e 0 exclusões
  1. 85 0
      src/groupUtils/groupFirstUtils.js

+ 85 - 0
src/groupUtils/groupFirstUtils.js

@@ -35,4 +35,89 @@ function chunkArrayTest() {
   // [[1, 2, 3],
   // [4, 5, 6],
   // [7, 8]]
+
+  const letJsonObj = {
+    productList: [
+      {
+        id: 1,
+        name: "商品A",
+        price: 29.9
+      },
+      {
+        id: 2,
+        name: "商品B",
+        price: 39.9
+      },
+      {
+        id: 3,
+        name: "商品C",
+        price: 19.9
+      },
+      {
+        id: 4,
+        name: "商品D",
+        price: 49.9
+      },
+      {
+        id: 5,
+        name: "商品E",
+        price: 59.9
+      },
+      {
+        id: 6,
+        name: "商品F",
+        price: 69.9
+      },
+      {
+        id: 7,
+        name: "商品G",
+        price: 79.9
+      }
+    ],
+    pageSize: 3,
+    expectedChunks: [
+      [
+        {
+          id: 1,
+          name: "商品A",
+          price: 29.9
+        },
+        {
+          id: 2,
+          name: "商品B",
+          price: 39.9
+        },
+        {
+          id: 3,
+          name: "商品C",
+          price: 19.9
+        }
+      ],
+      [
+        {
+          id: 4,
+          name: "商品D",
+          price: 49.9
+        },
+        {
+          id: 5,
+          name: "商品E",
+          price: 59.9
+        },
+        {
+          id: 6,
+          name: "商品F",
+          price: 69.9
+        }
+      ],
+      [
+        {
+          id: 7,
+          name: "商品G",
+          price: 79.9
+        }
+      ]
+    ]
+  };
+  const chunker = chunkSecondArray(letJsonObj.productList, letJsonObj.pageSize);
 }