如何在react-admin中自定义每个页面上的标题

问题描述 投票:0回答:1

我想将每个页面上的标题更改为React-Admin中的自定义需求,列表或编辑或创建复合材料中是否有特定属性?请指导我谢谢

enter image description here

reactjs react-admin
1个回答
0
投票

列表,显示,创建和更新组件都接受标题属性,它可以是字符串,也可以是您自己的元素。

<List {...props} title="My custom title">
    ...
</List>

const PostTitle = props => {
    return <span>Post {props.record ? `"${props.record.title}"` : ''}</span>;
};

export const PostShow = (props) => (
    <Show title={<PostTitle />} {...props}>
        ...
    </Show>
);

如果您想在菜单中更改名称,则可以将带有标签的选项prop传递给Resource:

<Resource ... options={{label: "Custom menu name"}}>

对于多语言应用程序,这是通过Admin上的i18nProvider属性完成的>

© www.soinside.com 2019 - 2024. All rights reserved.