fat-design 0.0.1-beta.20250927122721 → 0.0.1-beta.20250927134846
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +576 -1
- package/index.browser.js +12 -12
- package/index.js +1229 -1217
- package/index.umd.cjs +11 -11
- package/index.umd.js +11 -11
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1 +1,576 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Fat Design 组件库使用指南
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
<h1>🎨 Fat Design</h1>
|
|
5
|
+
<p>一套功能强大、体积轻量的 React 组件库</p>
|
|
6
|
+
|
|
7
|
+
<p>
|
|
8
|
+
项目网站:
|
|
9
|
+
https://uifaas.com/ns/app/fat-design-doc/index
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
<p>
|
|
13
|
+
<img src="https://img.shields.io/badge/React-16%2B-blue" alt="React 版本" />
|
|
14
|
+
<img src="https://img.shields.io/badge/TypeScript-4.9%2B-blue" alt="TypeScript 版本" />
|
|
15
|
+
<img src="https://img.shields.io/badge/Bundle%20Size-761KB-green" alt="包大小" />
|
|
16
|
+
</p>
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
## ✨ 特性
|
|
20
|
+
|
|
21
|
+
- 🎯 **体积轻量**:构建后仅 761KB,比同类产品小 30%+
|
|
22
|
+
- 🚀 **功能强大**:提供 60+ 高质量组件,涵盖企业级应用的各种场景
|
|
23
|
+
- 💪 **兼容性强**:支持 React 16、17、18 多个版本
|
|
24
|
+
- 🎨 **主题丰富**:内置 11 套精美主题,支持自定义主题
|
|
25
|
+
- 📦 **按需加载**:支持 Tree Shaking,减少打包体积
|
|
26
|
+
- 🛡️ **类型安全**:完整的 TypeScript 支持
|
|
27
|
+
- 📚 **文档完善**:详细的组件文档和丰富的示例
|
|
28
|
+
|
|
29
|
+
## 🎯 对比优势
|
|
30
|
+
|
|
31
|
+
与其他主流组件库相比:
|
|
32
|
+
|
|
33
|
+
| 特性 | Fat Design | Ant Design | Next UI |
|
|
34
|
+
|------|------------|------------|----------|
|
|
35
|
+
| 包体积 | 761KB | 1.2MB+ | 1.1MB+ |
|
|
36
|
+
| React 版本支持 | 16/17/18 | 16/17/18 | 17/18 |
|
|
37
|
+
| TypeScript | ✅ 完整支持 | ✅ 完整支持 | ✅ 完整支持 |
|
|
38
|
+
| 主题系统 | 11 套预设主题 | 默认主题 | 多套主题 |
|
|
39
|
+
| 高级组件 | Form、TablePro、QueryForm | 基础组件 | 基础组件 |
|
|
40
|
+
|
|
41
|
+
## 📦 安装
|
|
42
|
+
|
|
43
|
+
### 使用 npm
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# 安装最新版本
|
|
47
|
+
npm install fat-design
|
|
48
|
+
|
|
49
|
+
# 安装指定版本
|
|
50
|
+
npm install fat-design@latest
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 使用 yarn
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
# 安装最新版本
|
|
57
|
+
yarn add fat-design
|
|
58
|
+
|
|
59
|
+
# 安装指定版本
|
|
60
|
+
yarn add fat-design@latest
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 使用 pnpm
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# 安装最新版本
|
|
67
|
+
pnpm add fat-design
|
|
68
|
+
|
|
69
|
+
# 安装指定版本
|
|
70
|
+
pnpm add fat-design@latest
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## 🚀 快速开始
|
|
74
|
+
|
|
75
|
+
### 1. 引入样式
|
|
76
|
+
|
|
77
|
+
在项目入口文件中引入样式文件:
|
|
78
|
+
|
|
79
|
+
```javascript
|
|
80
|
+
// 引入默认主题
|
|
81
|
+
import 'fat-design/dist/theme-default.css'
|
|
82
|
+
|
|
83
|
+
// 或选择其他主题
|
|
84
|
+
import 'fat-design/dist/theme-blue1.css'
|
|
85
|
+
import 'fat-design/dist/theme-green.css'
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### 2. 使用组件
|
|
89
|
+
|
|
90
|
+
#### 全量导入(不推荐)
|
|
91
|
+
|
|
92
|
+
```javascript
|
|
93
|
+
import FatDesign from 'fat-design'
|
|
94
|
+
|
|
95
|
+
function App() {
|
|
96
|
+
return (
|
|
97
|
+
<div>
|
|
98
|
+
<FatDesign.Button type="primary">点击我</FatDesign.Button>
|
|
99
|
+
</div>
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
#### 按需导入(推荐)
|
|
105
|
+
|
|
106
|
+
```javascript
|
|
107
|
+
import { Button, Form, Table, Message } from 'fat-design'
|
|
108
|
+
|
|
109
|
+
function App() {
|
|
110
|
+
const handleClick = () => {
|
|
111
|
+
Message.success('按钮被点击了!')
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<div>
|
|
116
|
+
<Button type="primary" onClick={handleClick}>
|
|
117
|
+
点击我
|
|
118
|
+
</Button>
|
|
119
|
+
</div>
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### 3. 完整示例
|
|
125
|
+
|
|
126
|
+
```javascript
|
|
127
|
+
import React from 'react'
|
|
128
|
+
import {
|
|
129
|
+
Button,
|
|
130
|
+
Form,
|
|
131
|
+
Input,
|
|
132
|
+
Select,
|
|
133
|
+
DatePicker,
|
|
134
|
+
Message,
|
|
135
|
+
Card
|
|
136
|
+
} from 'fat-design'
|
|
137
|
+
import 'fat-design/dist/theme-default.css'
|
|
138
|
+
|
|
139
|
+
function App() {
|
|
140
|
+
const [form] = Form.useForm()
|
|
141
|
+
|
|
142
|
+
const handleSubmit = (values) => {
|
|
143
|
+
console.log('表单数据:', values)
|
|
144
|
+
Message.success('提交成功!')
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return (
|
|
148
|
+
<Card title="用户信息" style={{ maxWidth: 600, margin: '50px auto' }}>
|
|
149
|
+
<Form
|
|
150
|
+
form={form}
|
|
151
|
+
onFinish={handleSubmit}
|
|
152
|
+
labelCol={{ span: 6 }}
|
|
153
|
+
wrapperCol={{ span: 18 }}
|
|
154
|
+
>
|
|
155
|
+
<Form.Item
|
|
156
|
+
label="用户名"
|
|
157
|
+
name="username"
|
|
158
|
+
rules={[{ required: true, message: '请输入用户名' }]}
|
|
159
|
+
>
|
|
160
|
+
<Input placeholder="请输入用户名" />
|
|
161
|
+
</Form.Item>
|
|
162
|
+
|
|
163
|
+
<Form.Item
|
|
164
|
+
label="性别"
|
|
165
|
+
name="gender"
|
|
166
|
+
rules={[{ required: true, message: '请选择性别' }]}
|
|
167
|
+
>
|
|
168
|
+
<Select placeholder="请选择性别">
|
|
169
|
+
<Select.Option value="male">男</Select.Option>
|
|
170
|
+
<Select.Option value="female">女</Select.Option>
|
|
171
|
+
</Select>
|
|
172
|
+
</Form.Item>
|
|
173
|
+
|
|
174
|
+
<Form.Item
|
|
175
|
+
label="生日"
|
|
176
|
+
name="birthday"
|
|
177
|
+
>
|
|
178
|
+
<DatePicker placeholder="请选择生日" />
|
|
179
|
+
</Form.Item>
|
|
180
|
+
|
|
181
|
+
<Form.Item wrapperCol={{ offset: 6, span: 18 }}>
|
|
182
|
+
<Button type="primary" htmlType="submit">
|
|
183
|
+
提交
|
|
184
|
+
</Button>
|
|
185
|
+
<Button style={{ marginLeft: 8 }} onClick={() => form.resetFields()}>
|
|
186
|
+
重置
|
|
187
|
+
</Button>
|
|
188
|
+
</Form.Item>
|
|
189
|
+
</Form>
|
|
190
|
+
</Card>
|
|
191
|
+
)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export default App
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## 🎨 主题系统
|
|
198
|
+
|
|
199
|
+
Fat Design 提供了丰富的主题系统,包含 11 套精美的预设主题:
|
|
200
|
+
|
|
201
|
+
### 预设主题
|
|
202
|
+
|
|
203
|
+
```javascript
|
|
204
|
+
// 默认主题
|
|
205
|
+
import 'fat-design/dist/theme-default.css'
|
|
206
|
+
|
|
207
|
+
// 蓝色系主题
|
|
208
|
+
import 'fat-design/dist/theme-blue1.css'
|
|
209
|
+
import 'fat-design/dist/theme-blue2.css'
|
|
210
|
+
import 'fat-design/dist/theme-blue3.css'
|
|
211
|
+
import 'fat-design/dist/theme-blue4.css'
|
|
212
|
+
|
|
213
|
+
// 绿色系主题
|
|
214
|
+
import 'fat-design/dist/theme-green.css'
|
|
215
|
+
import 'fat-design/dist/theme-green2.css'
|
|
216
|
+
|
|
217
|
+
// 其他颜色主题
|
|
218
|
+
import 'fat-design/dist/theme-orange.css'
|
|
219
|
+
import 'fat-design/dist/theme-pink.css'
|
|
220
|
+
import 'fat-design/dist/theme-purple.css'
|
|
221
|
+
import 'fat-design/dist/theme-red.css'
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### 动态切换主题
|
|
225
|
+
|
|
226
|
+
```javascript
|
|
227
|
+
function changeTheme(themeName) {
|
|
228
|
+
const link = document.getElementById('fat-design-theme')
|
|
229
|
+
if (link) {
|
|
230
|
+
link.href = `/node_modules/fat-design/dist/${themeName}.css`
|
|
231
|
+
} else {
|
|
232
|
+
const newLink = document.createElement('link')
|
|
233
|
+
newLink.id = 'fat-design-theme'
|
|
234
|
+
newLink.rel = 'stylesheet'
|
|
235
|
+
newLink.href = `/node_modules/fat-design/dist/${themeName}.css`
|
|
236
|
+
document.head.appendChild(newLink)
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// 使用示例
|
|
241
|
+
changeTheme('theme-blue1')
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### 自定义主题
|
|
245
|
+
|
|
246
|
+
```scss
|
|
247
|
+
// 自定义主题变量
|
|
248
|
+
:root {
|
|
249
|
+
--color-brand1-1: #f0f8ff;
|
|
250
|
+
--color-brand1-6: #4169e1;
|
|
251
|
+
--color-brand1-9: #0000cd;
|
|
252
|
+
|
|
253
|
+
--color-text1-1: #666;
|
|
254
|
+
--color-text1-2: #333;
|
|
255
|
+
--color-text1-3: #000;
|
|
256
|
+
|
|
257
|
+
--color-line1-1: #eee;
|
|
258
|
+
--color-line1-2: #ddd;
|
|
259
|
+
--color-line1-3: #ccc;
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
## 📚 核心组件
|
|
264
|
+
|
|
265
|
+
### 基础组件
|
|
266
|
+
|
|
267
|
+
- **Button 按钮**:支持多种类型、尺寸、状态的按钮组件
|
|
268
|
+
- **Icon 图标**:丰富的图标库
|
|
269
|
+
- **Avatar 头像**:用户头像展示组件
|
|
270
|
+
- **Badge 徽标**:消息提醒、状态标识组件
|
|
271
|
+
|
|
272
|
+
### 布局组件
|
|
273
|
+
|
|
274
|
+
- **Grid 栅格**:24 栅格系统
|
|
275
|
+
- **Box 盒子**:灵活的布局容器
|
|
276
|
+
- **Divider 分割线**:内容分割组件
|
|
277
|
+
|
|
278
|
+
### 表单组件
|
|
279
|
+
|
|
280
|
+
- **Form/Form2 表单**:强大的表单解决方案
|
|
281
|
+
- **Input 输入框**:文本输入组件
|
|
282
|
+
- **Select 选择器**:下拉选择组件
|
|
283
|
+
- **DatePicker 日期选择**:日期时间选择组件
|
|
284
|
+
- **Checkbox 复选框**:多选组件
|
|
285
|
+
- **Radio 单选框**:单选组件
|
|
286
|
+
- **Switch 开关**:开关切换组件
|
|
287
|
+
- **BatchInput 批量输入**:批量数据输入组件
|
|
288
|
+
|
|
289
|
+
### 数据展示
|
|
290
|
+
|
|
291
|
+
- **Table 表格**:基础表格组件
|
|
292
|
+
- **TablePro 增强表格**:高级表格功能
|
|
293
|
+
- **Tree 树形控件**:层级数据展示
|
|
294
|
+
- **Tag 标签**:标记和分类
|
|
295
|
+
- **Timeline 时间轴**:时间流展示
|
|
296
|
+
|
|
297
|
+
### 反馈组件
|
|
298
|
+
|
|
299
|
+
- **Message 全局提示**:操作反馈信息
|
|
300
|
+
- **Notification 通知提醒**:系统通知
|
|
301
|
+
- **Dialog 对话框**:模态对话框
|
|
302
|
+
- **Drawer 抽屉**:侧边抽屉
|
|
303
|
+
- **Loading 加载**:加载状态提示
|
|
304
|
+
|
|
305
|
+
### 导航组件
|
|
306
|
+
|
|
307
|
+
- **Menu 导航菜单**:导航菜单组件
|
|
308
|
+
- **Breadcrumb 面包屑**:页面导航路径
|
|
309
|
+
- **Pagination 分页**:数据分页组件
|
|
310
|
+
- **Nav 导航**:页面导航组件
|
|
311
|
+
|
|
312
|
+
### 高级组件
|
|
313
|
+
|
|
314
|
+
- **Image 图片**:图片展示和预览
|
|
315
|
+
- **Upload 上传**:文件上传组件
|
|
316
|
+
- **SortableList 可排序列表**:拖拽排序列表
|
|
317
|
+
- **VirtualList 虚拟列表**:大数据量列表
|
|
318
|
+
- **QueryForm 查询表单**:搜索表单组件
|
|
319
|
+
|
|
320
|
+
## 🔧 构建工具集成
|
|
321
|
+
|
|
322
|
+
### Vite 集成(推荐)
|
|
323
|
+
|
|
324
|
+
```javascript
|
|
325
|
+
// vite.config.ts
|
|
326
|
+
import { defineConfig } from 'vite'
|
|
327
|
+
import react from '@vitejs/plugin-react'
|
|
328
|
+
|
|
329
|
+
export default defineConfig({
|
|
330
|
+
plugins: [react()],
|
|
331
|
+
css: {
|
|
332
|
+
preprocessorOptions: {
|
|
333
|
+
scss: {
|
|
334
|
+
additionalData: `@import "fat-design/dist/variables.scss";`
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
})
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
### Webpack 集成
|
|
342
|
+
|
|
343
|
+
```javascript
|
|
344
|
+
// webpack.config.js
|
|
345
|
+
module.exports = {
|
|
346
|
+
module: {
|
|
347
|
+
rules: [
|
|
348
|
+
{
|
|
349
|
+
test: /\.scss$/,
|
|
350
|
+
use: ['style-loader', 'css-loader', 'sass-loader']
|
|
351
|
+
}
|
|
352
|
+
]
|
|
353
|
+
},
|
|
354
|
+
externals: {
|
|
355
|
+
react: 'React',
|
|
356
|
+
'react-dom': 'ReactDOM'
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### Next.js 集成
|
|
362
|
+
|
|
363
|
+
```javascript
|
|
364
|
+
// next.config.js
|
|
365
|
+
module.exports = {
|
|
366
|
+
transpilePackages: ['fat-design'],
|
|
367
|
+
experimental: {
|
|
368
|
+
esmExternals: 'loose'
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
## 🛠️ TypeScript 支持
|
|
374
|
+
|
|
375
|
+
Fat Design 提供完整的 TypeScript 类型定义:
|
|
376
|
+
|
|
377
|
+
```typescript
|
|
378
|
+
import { ButtonProps, FormProps, TableProps } from 'fat-design'
|
|
379
|
+
|
|
380
|
+
// 组件 Props 类型
|
|
381
|
+
const buttonProps: ButtonProps = {
|
|
382
|
+
type: 'primary',
|
|
383
|
+
size: 'medium',
|
|
384
|
+
onClick: () => console.log('clicked')
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// 表单验证
|
|
388
|
+
interface FormData {
|
|
389
|
+
username: string
|
|
390
|
+
email: string
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
const formProps: FormProps<FormData> = {
|
|
394
|
+
onFinish: (values: FormData) => {
|
|
395
|
+
console.log(values.username, values.email)
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
## 🔍 按需加载
|
|
401
|
+
|
|
402
|
+
为了减少打包体积,推荐使用按需加载:
|
|
403
|
+
|
|
404
|
+
```javascript
|
|
405
|
+
// 推荐写法 - 自动 Tree Shaking
|
|
406
|
+
import { Button, Form, Table } from 'fat-design'
|
|
407
|
+
|
|
408
|
+
// 避免以下写法
|
|
409
|
+
import FatDesign from 'fat-design' // ❌
|
|
410
|
+
import * as FatDesign from 'fat-design' // ❌
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
## 🐛 常见问题
|
|
414
|
+
|
|
415
|
+
### 1. React 版本兼容性
|
|
416
|
+
|
|
417
|
+
Fat Design 支持 React 16、17、18,如遇到兼容性问题:
|
|
418
|
+
|
|
419
|
+
```javascript
|
|
420
|
+
import { tryAutoConfig } from 'fat-design'
|
|
421
|
+
|
|
422
|
+
// 自动配置
|
|
423
|
+
tryAutoConfig()
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
### 2. 样式问题
|
|
427
|
+
|
|
428
|
+
如果样式没有正确加载,请确保:
|
|
429
|
+
|
|
430
|
+
```javascript
|
|
431
|
+
// 1. 正确引入样式文件
|
|
432
|
+
import 'fat-design/dist/theme-default.css'
|
|
433
|
+
|
|
434
|
+
// 2. 检查 CSS 加载器配置
|
|
435
|
+
// 3. 确保样式文件路径正确
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
### 3. TypeScript 类型错误
|
|
439
|
+
|
|
440
|
+
```typescript
|
|
441
|
+
// tsconfig.json 配置
|
|
442
|
+
{
|
|
443
|
+
"compilerOptions": {
|
|
444
|
+
"typeRoots": ["node_modules/@types", "node_modules/fat-design/types"],
|
|
445
|
+
"types": ["fat-design"]
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
## 📖 进阶使用
|
|
451
|
+
|
|
452
|
+
### 自定义 Hook
|
|
453
|
+
|
|
454
|
+
```javascript
|
|
455
|
+
import { hooks } from 'fat-design'
|
|
456
|
+
|
|
457
|
+
function MyComponent() {
|
|
458
|
+
const [value, setValue] = hooks.useCurrentState('')
|
|
459
|
+
const persistFn = hooks.usePersistFn(() => {
|
|
460
|
+
console.log('持久化函数')
|
|
461
|
+
})
|
|
462
|
+
|
|
463
|
+
return <div>{/* 组件内容 */}</div>
|
|
464
|
+
}
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
### 工具函数
|
|
468
|
+
|
|
469
|
+
```javascript
|
|
470
|
+
import { utils } from 'fat-design'
|
|
471
|
+
|
|
472
|
+
// ID 生成
|
|
473
|
+
const id = utils.generateId()
|
|
474
|
+
|
|
475
|
+
// 对象操作
|
|
476
|
+
const isEqual = utils.shallowEqual(obj1, obj2)
|
|
477
|
+
|
|
478
|
+
// DOM 操作
|
|
479
|
+
const element = utils.findDOMNode(ref.current)
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
## 🌟 最佳实践
|
|
483
|
+
|
|
484
|
+
### 1. 组件设计
|
|
485
|
+
|
|
486
|
+
```javascript
|
|
487
|
+
// 推荐:组合使用组件
|
|
488
|
+
function UserCard({ user }) {
|
|
489
|
+
return (
|
|
490
|
+
<Card
|
|
491
|
+
title={
|
|
492
|
+
<div>
|
|
493
|
+
<Avatar src={user.avatar} />
|
|
494
|
+
<span>{user.name}</span>
|
|
495
|
+
</div>
|
|
496
|
+
}
|
|
497
|
+
extra={<Tag color="blue">{user.role}</Tag>}
|
|
498
|
+
>
|
|
499
|
+
<p>{user.description}</p>
|
|
500
|
+
</Card>
|
|
501
|
+
)
|
|
502
|
+
}
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
### 2. 表单处理
|
|
506
|
+
|
|
507
|
+
```javascript
|
|
508
|
+
// 推荐:使用 Form2 处理复杂表单
|
|
509
|
+
function UserForm() {
|
|
510
|
+
return (
|
|
511
|
+
<Form
|
|
512
|
+
labelCol={{ span: 6 }}
|
|
513
|
+
wrapperCol={{ span: 18 }}
|
|
514
|
+
onFinish={handleSubmit}
|
|
515
|
+
>
|
|
516
|
+
<Form.Item name="username" label="用户名" rules={[{ required: true }]}>
|
|
517
|
+
<Input />
|
|
518
|
+
</Form.Item>
|
|
519
|
+
|
|
520
|
+
<Form.Item name="profile" label="个人信息">
|
|
521
|
+
<Form
|
|
522
|
+
layout="inline"
|
|
523
|
+
initialValues={{ age: 18 }}
|
|
524
|
+
>
|
|
525
|
+
<Form.Item name="age" label="年龄">
|
|
526
|
+
<NumberPicker />
|
|
527
|
+
</Form.Item>
|
|
528
|
+
<Form.Item name="city" label="城市">
|
|
529
|
+
<Select />
|
|
530
|
+
</Form.Item>
|
|
531
|
+
</Form>
|
|
532
|
+
</Form.Item>
|
|
533
|
+
</Form>
|
|
534
|
+
)
|
|
535
|
+
}
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
### 3. 数据展示
|
|
539
|
+
|
|
540
|
+
```javascript
|
|
541
|
+
// 推荐:使用 TablePro 处理复杂表格
|
|
542
|
+
function UserTable() {
|
|
543
|
+
const columns = [
|
|
544
|
+
{
|
|
545
|
+
title: '用户名',
|
|
546
|
+
dataIndex: 'username',
|
|
547
|
+
sorter: true,
|
|
548
|
+
filter: true
|
|
549
|
+
},
|
|
550
|
+
{
|
|
551
|
+
title: '状态',
|
|
552
|
+
dataIndex: 'status',
|
|
553
|
+
render: (status) => (
|
|
554
|
+
<Tag color={status === 'active' ? 'green' : 'red'}>
|
|
555
|
+
{status}
|
|
556
|
+
</Tag>
|
|
557
|
+
)
|
|
558
|
+
}
|
|
559
|
+
]
|
|
560
|
+
|
|
561
|
+
return (
|
|
562
|
+
<TablePro
|
|
563
|
+
columns={columns}
|
|
564
|
+
dataSource={users}
|
|
565
|
+
pagination={{ pageSize: 10 }}
|
|
566
|
+
toolbar={{
|
|
567
|
+
search: true,
|
|
568
|
+
filter: true,
|
|
569
|
+
export: true
|
|
570
|
+
}}
|
|
571
|
+
/>
|
|
572
|
+
)
|
|
573
|
+
}
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
|