【山竹记账前端-react】17.Grid + Flex 布局实战
大纲链接 §
[toc]
1. 记账页面 ⇧
- 包括收入、支出tab切换
- tab内容中的标签列表,添加标签按钮
- 输入日期、金额显示,数字按钮键盘
2. Tabs组件与泛型组件 ⇧
添加路由,新建页面组件 ⇧
@/route/routes.tsx
|
|
@/pages/ItemCreatePage.tsx
|
|
封装 SwitchTabs 泛型组件 ⇧
@/components/SwitchTabs.tsx
|
|
- 去除函数组建声明
: React.FC<Props> - 参数前声明泛型
<T extends string>- 泛型参数
T用于限制tabItems中的key类型为string
- 泛型参数
- 参数后声明类型
{ className, tabItems, selectedTabKey, onSwitchTab, }: Props<T>) - 声明外部参数
interface Props<T>传类型参数T- 声明
selectedTabKey: T - 声明
tabItems: Readonly<Array<{ key: T; text: string }>> - 声明
onSwitchTab: (key: T) => void
- 声明
重构
@/components/DateRangePicker.tsx
|
|
重构
@/pages/ItemsPage.tsx
|
|
3. 完成顶部导航栏 ⇧
4. Tabs内容与classPrefix ⇧
5. Grid布局展示所有标签 ⇧
6. 完善样式细节 ⇧
7. 这个布局写得好 ⇧
8. 使用 vh-check 解决全屏 bug ⇧
9. 消除 key 警告 ⇧
·未完待续·
参考文章
- 初始代码:https://github.com/FrankFang/3iw2WJa
- 提交记录(新增了 9 个):https://github.com/FrankFang/rB4yHD/commits/master
- 最终代码:https://github.com/FrankFang/rB4yHD
相关文章
- 无
- 作者: Joel
- 文章链接:
- 版权声明
- 非自由转载-非商用-非衍生-保持署名