为什么我在 row.join() 函数中出错?
Why am I getting error in row.join() function?
我正在尝试使用下一个代码生成一个 csv 文件。
function generaBlue() {
var taula = $("#divTaula")[0].childNodes;
var id = taula[0].getAttribute("id");
console.log(id.substr(0, id.indexOf("_")));
let table = $("#" + id.substr(0, id.indexOf("_"))).DataTable();
let data = table.rows().data();
let text = "";
data.map((row) => (text += row.join(";") + "\n"));
let blob = new Blob([text], { type: "text/csv;charset=utf-8" });
saveAs(blob, "prova.csv");
}
并且 row.join(';') 返回此错误:
TypeError: row.join is not a function
问题是我收到了一组不接受连接函数的对象。
function generaBlue() {
var taula = $("#divTaula")[0].childNodes;
var id = taula[0].getAttribute("id");
console.log(id.substr(0, id.indexOf("_")));
let table = $("#" + id.substr(0, id.indexOf("_"))).DataTable();
let data = table.rows().data();
let text = data.reduce((a, c) => a + Object.values(c).join(";") + "\n", "");
let blob = new Blob([text], { type: "text/csv;charset=utf-8" });
saveAs(blob, "prova.csv");
}
我正在尝试使用下一个代码生成一个 csv 文件。
function generaBlue() {
var taula = $("#divTaula")[0].childNodes;
var id = taula[0].getAttribute("id");
console.log(id.substr(0, id.indexOf("_")));
let table = $("#" + id.substr(0, id.indexOf("_"))).DataTable();
let data = table.rows().data();
let text = "";
data.map((row) => (text += row.join(";") + "\n"));
let blob = new Blob([text], { type: "text/csv;charset=utf-8" });
saveAs(blob, "prova.csv");
}
并且 row.join(';') 返回此错误:
TypeError: row.join is not a function
问题是我收到了一组不接受连接函数的对象。
function generaBlue() {
var taula = $("#divTaula")[0].childNodes;
var id = taula[0].getAttribute("id");
console.log(id.substr(0, id.indexOf("_")));
let table = $("#" + id.substr(0, id.indexOf("_"))).DataTable();
let data = table.rows().data();
let text = data.reduce((a, c) => a + Object.values(c).join(";") + "\n", "");
let blob = new Blob([text], { type: "text/csv;charset=utf-8" });
saveAs(blob, "prova.csv");
}