我遵循了有关将数据从我的应用程序导出到CSV文件的教程 但我收到未定义的错误:
./src/components/index.component.js
Line 37:9: 'csvRow' is not defined no-undef
Line 39:21: 'csvRow' is not defined no-undef
Line 39:36: 'OA' is not defined no-undef
Search for the keywords to learn more about each error.
这是我的CSV导出代码:
csvData: [
{
'personName': '',
'businessName': '',
'date': '',
'activity': '',
'hours': '',
'learningStatement': ''
}
]
};
}
exportCsv() {
var cvsRow=[];
var A = [['person', 'business', 'date', 'activity', 'hours', 'learningStatement']];
var re = this.state.csvData;
for(var item=0; item<re.length; item++)
{
A.push([item, re[item].person], re[item].business, re[item].date, re[item].activity, re[item].hours, re[item].learningStatement]);
}
// console.log(A);
for(var i=0; i<A.length; ++i)
{
csvRow.push(A[i].join(","))
}
var csvString=csvRow.join(""%OA);
var a=document.createElement("a");
a.href='data:attachment/csv.' + csvString;
a.target='_Blank';
a.download= 'testfile.csv';
document.body.appendChild(a);
a.click();
};
我还没有处理这种功能,所以我不知道自己是否走对了。