无法生成FileInput,它会在渲染过程中抛出错误

时间:2018-03-16 10:47:18

标签: javascript reactjs admin-on-rest

您想要做的是在Admin On Rest面板的Create操作中创建FileInput。

以下是我的创建操作定义。

import React from 'react';
import {Create, SimpleForm, TextInput, ReferenceInput, SelectInput, FileInput, FileField} from 'admin-on-rest';

export default (props) => (
  <Create {...props}>
    <SimpleForm>
      <TextInput source="name" />
      <ReferenceInput label="Project" source="projectId" reference="projects" allowEmpty>
        <SelectInput optionText="name"/>
      </ReferenceInput>
    </SimpleForm>
    <FileInput source="files" label="Related files" accept="application/pdf">
      <FileField source="src" title="title" />
    </FileInput>
  </Create>
);

它会引发https://pastebin.com/E6zae4k6

等错误

你有什么想法吗?

1 个答案:

答案 0 :(得分:0)

import React from 'react';
import {Create, SimpleForm, TextInput, ReferenceInput, SelectInput, FileInput, FileField} from 'admin-on-rest';

export default (props) => (
  <Create {...props}>
    <SimpleForm>
      <TextInput source="name" />
      <ReferenceInput label="Project" source="projectId" reference="projects" allowEmpty>
        <SelectInput optionText="name"/>
      </ReferenceInput>
      <FileInput source="files" label="Related files" accept="application/pdf">
        <FileField source="src" title="title" />
      </FileInput>
    </SimpleForm>
  </Create>
);