1
0
mirror of https://gitee.com/bookshelfplus/bookshelfplus synced 2025-09-02 23:23:28 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

表格渲染考虑无满足条件传入提示字符串的情况

This commit is contained in:
2022-03-15 23:31:48 +08:00
parent 80a5b59bdf
commit 4ceb7578b8
2 changed files with 10 additions and 10 deletions

View File

@@ -52,8 +52,12 @@ function renderTable({
}
theadHtml += "</tr>";
}
} else if (typeof data === "string") {
// 是文字 (一般用于未查到结果,显示提示信息)
theadHtml += `<tr><th>${data}</th></tr>`;
} else {
throw new DOMException("Failed to render table: data is not array or dictionary.");
throw new DOMException("Failed to render table: data is not array, dictionary or string.");
}
// 获取table

View File

@@ -58,7 +58,7 @@
var status = axiosData.status;
var data = axiosData.data;
if (status === "success") {
console.log(data)
// console.log(data)
// 数据进行转换
var renderData = [];
@@ -87,16 +87,12 @@
</span>`,
})
});
if(renderData.length == 0) {
renderData.push({
书名: "没有搜索到相关书籍",
分类: "",
简介: "",
语言: "",
出版社: "",
})
renderTable({ data: "没有搜索到相关书籍", tableId: "result-table", renderTableHead: true });
} else {
renderTable({ data: renderData, tableId: "result-table", renderTableHead: true });
}
renderTable({ data: renderData, tableId: "result-table", renderTableHead: true });
// renderTable({ data: data, tableId: "origin-table", renderTableHead: true });
// 渲染后重新获取一次字体