【问题标题】:How to do a custom api call in a custom field?如何在自定义字段中进行自定义 api 调用?
【发布时间】:2019-02-14 11:01:15
【问题描述】:

我是 react-admin 的新手,我需要创建一个自定义字段。

我想从端点获取信息列表(例如 3 个对象)。

然后我需要在我的自定义字段(一个组件)上创建 3 NumberInput(基于列表)

const CustomInput = () => (
    <div>
        <NumberInput source="foo" label="bar" />
        <NumberInput source="foo2" label="bar2" />
        <NumberInput source="foo3" label="bar3" />
    </div>
);

我想替换这 3 个 NumberInput 以从我的端点列表中动态呈现它们。

如何使用 react-admin 做到这一点:

  • 调用我的端点以获取列表
  • 使用列表循环并动态创建NumberInput

谢谢 ;)

【问题讨论】:

    标签: react-admin


    【解决方案1】:

    react-admin 只是一堆反应组件。您可以像在任何 React 应用程序中一样执行此操作。例如,在您的 componentDidMount 方法中对您的 API 调用 fetch

    【讨论】:

      猜你喜欢
      • 2020-09-30
      • 2017-04-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-29
      • 2016-07-22
      相关资源
      最近更新 更多