1. 安装react-helmet-async
npm install react-helmet-async -S
2. 如下修改App.tsx即可
import { ConfigProvider } from "antd";
import { RouterProvider } from "react-router-dom";
import { router } from "/@/router";
import { Helmet, HelmetProvider } from "react-helmet-async";
const App = () => {
return (
<HelmetProvider>
<ConfigProvider
locale={locale}
theme={{
token: {
colorPrimary: "#F26722",
borderRadius: 2,
},
components: {
Modal: {
borderRadiusLG: 2,
},
Input: {
borderRadius: 2,
},
Button: {
borderRadius: 4,
},
},
}}
>
<RouterProvider router={router} />
</ConfigProvider>
<Helmet>
<title>你的默认页面标题</title>
</Helmet>
</HelmetProvider>
);
};
export default App;