Javascript 如何为材质UI的标题、正文和按钮标记设置自定义字体?

Javascript 如何为材质UI的标题、正文和按钮标记设置自定义字体?,javascript,reactjs,material-ui,Javascript,Reactjs,Material Ui,我正在使用createMuiTheme设置使用材质UI自定义我的主题。如何为标题、正文和按钮标记设置特定字体 我假设它将定制主题中的排版组件。然后从应用程序组件中选择它。但是找不到任何关于这个的文档 主题文件: import { createMuiTheme } from "@material-ui/core/styles"; export default createMuiTheme({ typography: { fontFamily: ["campton-book", "cam

我正在使用
createMuiTheme
设置使用材质UI自定义我的主题。如何为标题、正文和按钮标记设置特定字体

我假设它将定制主题中的排版组件。然后从应用程序组件中选择它。但是找不到任何关于这个的文档

主题文件:

import { createMuiTheme } from "@material-ui/core/styles";

export default createMuiTheme({
 typography: {
    fontFamily: ["campton-book", "campton-light", "campton-medium"].join(",")
//something here setting specific font family for specific tags?
  }
});

import React,{Component}来自“React”;
从“道具类型”导入道具类型;
从“@material ui/core/styles”导入{withStyles,MuiThemeProvider}”;
从“@material ui/core/Typography”导入排版;
从“./主题”导入主题;
常量样式=主题=>({
根目录:{
flexGrow:1
}
});
类工具扩展组件{
render(){
const{classes}=this.props;
返回(
此处的一些文本为h2和“campton light”字体系列
此处的一些文本为body1和“campton book”字体系列
此处的一些文字为上划线和“campton medium”字体系列
);
}
}
Apps.propTypes={
类:PropTypes.object.isRequired
};
导出默认样式(样式)(应用程序);

下面是控制不同文本变体字体系列的语法

查看主题中可用属性的最简单方法是查看默认主题的结构:


您是如何在应用程序中添加字体的?你在用网页包吗?
import React, { Component } from "react";
import PropTypes from "prop-types";
import { withStyles, MuiThemeProvider } from "@material-ui/core/styles";
import Typography from "@material-ui/core/Typography";
import Theme from "../Theme";

const styles = theme => ({
  root: {
    flexGrow: 1
  }
});

class Tools extends Component {
  render() {
    const { classes } = this.props;
    return (
      <MuiThemeProvider theme={Theme}>
       <Typography variant="h2">Some text here as h2 and the "campton-light" font family</Typography>
       <Typography variant="body1">Some text here as body1 and the "campton-book" font family</Typography>
       <Typography variant="overline">Some text here as overline and the "campton-medium" font family</Typography>
      </MuiThemeProvider>
    );
  }
}

Apps.propTypes = {
  classes: PropTypes.object.isRequired
};

export default withStyles(styles)(Apps);

const theme = createMuiTheme({
  typography: {
    h1: {
      fontFamily: "Comic Sans MS"
    },
    h2: {
      fontFamily: "Arial"
    },
    h3: {
      fontFamily: "Times New Roman"
    },
    h4: {
      fontFamily: "verdana"
    },
    button: {
      fontFamily: "Comic Sans MS"
    }
  }
});