javascript - 我可以在 jsPDF-autotable 正文中放置 for 循环吗?
问题描述
我在填充 jsPDF-autotable 正文时遇到了麻烦。我可以循环这样的东西吗?
doc.autoTable({
head: [this.pdf_head],
body: [
for(let i = 0; i < this.generated_table.length; i++)
{
for(let j = 0; j < this.generated_column.length; j++)
{
[this.pdf_body[i][j]];
}
}
],
})
我正在使用 vs-table 所以我不能使用 html 格式。此代码当前无法正常工作,但有没有办法做到这一点?谢谢!
解决方案
let bodyData = [];
for(let i = 0; i < this.generated_table.length; i++)
{
let rowData = [];
for(let j = 0; j < this.generated_column.length; j++)
{
rowData.push(this.pdf_body[i][j]);
}
bodyData.push(rowData);
}
doc.autoTable({
head: [this.pdf_head],
body: bodyData
})
你可以写这样的代码。
推荐阅读
- c++ - 关于 c++ 类接口设计的建议:您如何命名这两种方法以使其明显?
- python - Cython syntax for dataframe of dates and dictionaries as inputs to the function
- java - fragment is not responding the second time opened
- snowflake-cloud-data-platform - How to do select and union from group of tables using information schema in snowflake
- powerbi - 在 Powerbi 中转换为分钟值
- watson-nlu - Why is the Watson NLU Demo not fully functioning with the 'analyse text' button?
- linux - Why can't I "cat file > /dev/input/event"?
- javascript - 'Const' 未定义。(discord.js)
- intellij-idea - Intellij mc mod - 对象不是功能接口
- node.js - 开始使用 node.js 和 puppeteer 的问题