From 0289f389d70e3dbc8df7c2a9a9b86bacf727013d Mon Sep 17 00:00:00 2001 From: YangQi Date: Wed, 27 Jul 2022 14:09:06 +0800 Subject: [PATCH] fix: rendering failed table (#160) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `---` 两端存在 `\t` 导致无法表格成功渲染 --- src/assets/scripts/util.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/assets/scripts/util.js b/src/assets/scripts/util.js index 546bdbc..bb1c7d2 100644 --- a/src/assets/scripts/util.js +++ b/src/assets/scripts/util.js @@ -304,18 +304,15 @@ export function exportHTML() { */ export function createTable({ data, rows, cols }) { let table = `` - let currRow = [] for (let i = 0; i < rows + 2; ++i) { - table += `|\t` - currRow = [] + table += `| ` + const currRow = [] for (let j = 0; j < cols; ++j) { const rowIdx = i > 1 ? i - 1 : i - i === 1 - ? currRow.push(`---\t`) - : currRow.push(data[`k_${rowIdx}_${j}`] || ``) + currRow.push(i === 1 ? `---` : data[`k_${rowIdx}_${j}`] || ` `) } - table += currRow.join(`\t|\t`) - table += `\t|\n` + table += currRow.join(` | `) + table += ` |\n` } return table