我正尝试使用此代码在服务器端使用Iron-Router从Meteor导出CSV文件:
this.route('export_cand', { // Export Candidates
path: '/export/cand/:_id',
where: 'server',
action: function() {
headers={
'Content-type': 'text/csv',
'Content-Disposition': "attachment; filename=candidates.csv"
};
this.response.writeHead(200, headers);
strFile='contents of the CSV file';
this.response.end(strFile);
}
})
文件已成功生成,但网页会丢失所有收集信息。有什么想法发生了什么?