From d669404c929121c5027514acf1ec588c9c8c1496 Mon Sep 17 00:00:00 2001 From: pipipi-pikachu Date: Wed, 9 Jun 2021 15:35:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=96=B0=E5=BB=BA=E8=A1=A8=E6=A0=BC?= =?UTF-8?q?=E7=9A=84=E5=8D=95=E5=85=83=E6=A0=BCID=E9=87=8D=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useCreateElement.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/hooks/useCreateElement.ts b/src/hooks/useCreateElement.ts index e44e6a99..129ed9e3 100644 --- a/src/hooks/useCreateElement.ts +++ b/src/hooks/useCreateElement.ts @@ -103,8 +103,14 @@ export default () => { fontname: fontName.value, color: fontColor.value, } - const rowCells: TableCell[] = new Array(col).fill({ id: createRandomCode(), colspan: 1, rowspan: 1, text: '', style }) - const data: TableCell[][] = new Array(row).fill(rowCells) + const data: TableCell[][] = [] + for (let i = 0; i < row; i++) { + const rowCells: TableCell[] = [] + for (let j = 0; j < col; j++) { + rowCells.push({ id: createRandomCode(), colspan: 1, rowspan: 1, text: '', style }) + } + data.push(rowCells) + } const DEFAULT_CELL_WIDTH = 100 const DEFAULT_CELL_HEIGHT = 36