React Material UI 组件


2019-8-17 React Material UI

安装

# 安装核包
npm i @material-ui/core
# 安装字体文件
npm install typeface-roboto --save
#然后
import 'typeface-roboto';
# 安装字体图标
npm install @material-ui/icons

1
2
3
4
5
6
7
8
9

全局统一化

添加移动设备视口

<meta
  name="viewport"
  content="minimum-scale=1, initial-scale=1, width=device-width, shrink-to-fit=no"
/>
1
2
3
4

CssBaseline

可以提供全局样式统一格式化。

布局组件(layout)

Box

  1. 相当于一个DIV
  2. component可以更改其包裹元素
  3. 可以使用样式向其子组件传递
  4. 传递样式给子组件需要使用clone=bool
  5. 或者使用{props=>} 传递组件

Container

  1. 版心 水平居中
  2. fixed固定大小 maxWidth="sm"设置最大宽度

Grid 栅格

  1. 12列
  2. xs,sm,md,lg 和 xl。
  3. 自带两种布局containers和items
  4. 总是相对父元素流动缓缓大小,以百分比宽度设置大小
  5. 自带padding