react大屏引入其他字体
1.assets/font/font.js 引用woff2的转码url
import {
createGlobalStyle } from "styled-components";
export const TextFamily = createGlobalStyle` @font-face {font-family: "Grace"; src: // url('Grace-of-Etro.ttf') format('truetype'), url('data:application/x-font-woff2;charset=utf-8;base64,d09GMgABAAAAACHEABAAAAAAdTg...') format('woff2'), } .textFamily { font-family: "Grace" !important; font-style: normal; } `;
2.src/router.jsx
import React, { Fragment } from "react";
import { Router, Route, Switch } from "dva/router";
import IndexPage from "./routes/IndexPage";
import { Iconstyle } from "./assets/icon/iconfont";
import { Globalstyle } from "./style/global.js";
import { TextFamily } from "./assets/font/font.js"; //引入
// import "./assets/font/font.css";
function RouterConfig({ history }) {
const route = () => {
return (
<Fragment>
{/* 全局样式注册到界面中 */}
<TextFamily></TextFamily> //引入
<Iconstyle></Iconstyle>
<Globalstyle></Globalstyle>
{/* 路由管理 */}
<Switch>
<Route path="/" exact component={IndexPage} />
</Switch>
</Fragment>
);
};
return <Router history={history}>{route()}</Router>;
}
export default RouterConfig;
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/bian-cheng-ji-chu/106371.html