首页 > 解决方案 > 字体机器人是为了什么?

问题描述

鉴于下面的反应代码:

import React, { Component } from 'react';
import ReactDOM from 'react-dom';

import 'typeface-roboto';
import Typography from '@material-ui/core/Typography';

const App = class extends Component {
  render() {
    return <Typography variant="h1">Hello React App!</Typography>;
  }
}

const root = document.getElementById('root');

ReactDOM.render(<App />, root);

如果我评论import 'typeface-roboto';我的应用程序没有任何变化。

有人可以解释我为什么吗?

沙箱:https ://codesandbox.io/s/x2n59kj2lq

标签: reactjsmaterial-ui

解决方案


包'typeface-roboto'用于导入roboto字体,它包括所有必要的字体文件和一个CSS文件。只有当你想改变你的字体时才需要它。而且,typeface-roboto假设你使用webpack来处理CSS和文件。


推荐阅读