React Material UI 组件
Yu Lei 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
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
2
3
4
CssBaseline
可以提供全局样式统一格式化。
布局组件(layout)
Box
- 相当于一个DIV
- component可以更改其包裹元素
- 可以使用样式向其子组件传递
- 传递样式给子组件需要使用clone=bool
- 或者使用{props=>} 传递组件
Container
- 版心 水平居中
- fixed固定大小 maxWidth="sm"设置最大宽度
Grid 栅格
- 12列
- xs,sm,md,lg 和 xl。
- 自带两种布局containers和items
- 总是相对父元素流动缓缓大小,以百分比宽度设置大小
- 自带padding