【发布时间】:2021-08-30 17:28:23
【问题描述】:
我需要从服务器检索数据,然后将这些数据显示在表格中,如果用户单击表格中的按钮,他可以下载文件
这是我的数据:
files = [ {name : "file1", created_at: "29/01/2021"},
{name : "file2", created_at: "20/03/2021"}]
表格标题:
const tableColumns = [
{ title: "name", field: "name" },
{
title: "Date",
field: "created_at",
type: "date",
dateSetting: { locale: "en-GB" },
filterComponent: (props) => <CustomDatePicker {...props} />
}
];
我的数组:
{file && (
<Fragment>
<MaterialTable
columns={tableColumns}
data={file}
title="Material Table - Custom Filter Component"
options={{search: false, filtering: true }}
actions={[
{
icon: 'save',
tooltip: 'Save User',
onClick: () => window.open('http://localhost:5000/files/' + file.name, '_blank').focus()
}
]}
/>
</Fragment>)}
我收到错误:ENOENT: no such file or directory, stat '/Users/admin//files/undefined'"}
如何在 react js 中使用每个文件的链接,我尝试在我的数据上使用 map 函数但它不起作用
【问题讨论】:
-
嘿@Cissus 我刚刚回答了这个here。
标签: reactjs onclick material-table