React-Admin 不在列表组件中显示列数据

React-Admin doesn't show column data in List component

我似乎无法理解为什么数据会丢失。这是我的领域:

<ReferenceField source="imageId" reference="files">
        <TextField source="urlPath" />
</ReferenceField>

这是主要模型 papers 返回的内容:

brandId: "b3dc4246-3adf-4f4e-9f81-294f23d24977"
brandModelId: "2819360d-2e6e-48e4-88a3-823a03177a7c"
colorId: "98031f74-a83f-4389-b9d6-bab959ff8a0e"
gsm: 200
id: "058cc13d-1255-4d9b-9ccf-e087ddb3935d"
imageId: "1bc99717-f60c-485e-989a-5d1726501b8d"
originalSize: "A4"
paperMaterialId: "5afd0d7c-5ace-49e3-a538-894ce288fe71"
paperSurfaceId: null
price: 12
ref: "44202129"
storeId: "2f7567ad-fa62-4bda-851b-89b8c39a189e"

这是相关模型 files 返回的内容:

id: "1bc99717-f60c-485e-989a-5d1726501b8d"
originalFileName: "palette1.2.png"
type: "undefined"
urlPath: "asdf/101d7c68-9bf4-4d55-bbb5-818f62c480a3-palette1.2.png"

但这是我缺少数据的屏幕截图:

请注意,商店相关字段有效,它具有完全相同的代码:

      <ReferenceField source="storeId" reference="stores">
        <TextField source="name" />
      </ReferenceField>

此外,这是我的 getMany dataProvider:

  getMany: (resource, params) => {
    const query = {
      filter: JSON.stringify({ id: params.ids }),
    };
    const url = `${API_URL_LOCAL}/${resource}?${stringify(query)}`;

    return request(url, 'get', {}, {}).then(({ data }) => ({
      data,
    }));
  },

欢迎任何帮助。

如果您有一些参考字段在工作,而其他参考字段没有工作,并且控制台中没有记录错误,这可能意味着未使用 <Resource name="files" .../> 将非工作参考资源声明为 Admin child .

来自 react-admin 文档:

Note: You must add a <Resource> for the reference resource - react-admin needs it to fetch the reference data. You can omit the list prop in this reference if you want to hide it in the sidebar menu.

https://marmelab.com/react-admin/Fields.html#referencefield

如果 none 参考资源正在运行,并且资源已正确声明,则错误可能取决于您的数据提供者。记录 getMany 请求的响应并查看它是否符合预期格式以及它是否包含任何数据而不是空数组:

getMany     { data: {Record[]}, validUntil?: {Date} }

A {Record} is an object literal with at least an id property, e.g. { id: 123, title: "hello, world" }.

The validUntil field in the response is optional. It enables the Application cache, a client-side optimization to speed up rendering and reduce network traffic

https://marmelab.com/react-admin/DataProviders.html#writing-your-own-data-provider