@@ -10,50 +10,69 @@ demo:
1010
1111## 何时使用
1212
13- 当目前没有数据时,用于显式的用户提示。初始化场景时的引导创建流程
13+ - 当目前没有数据时,用于显式的用户提示。
14+ - 初始化场景时的引导创建流程。
15+ - 内置 6 种空状态类型。
1416
1517## 示例
1618
1719``` jsx
1820/**
19- * title="使用默认空状态 "
21+ * title: "使用内置状态 "
2022 */
21- import React from ' react' ;
23+ import React , { useState } from ' react' ;
2224import { Empty } from ' dt-react-component' ;
25+ import { Radio , Space } from ' antd' ;
2326
24- export default () => {
25- return < Empty / > ;
26- };
27- ```
27+ const options = [
28+ { label: ' default' , value: ' default' },
29+ { label: ' project' , value: ' project' },
30+ { label: ' chart' , value: ' chart' },
31+ { label: ' search' , value: ' search' },
32+ { label: ' permission' , value: ' permission' },
33+ { label: ' overview' , value: ' overview' },
34+ ];
2835
29- ``` jsx
30- /**
31- * title="使用别的空状态"
32- */
33- import React from ' react' ;
34- import { Empty } from ' dt-react-component' ;
35- import { Divider } from ' antd' ;
36+ const getEmpty = (type ) => {
37+ switch (type) {
38+ case ' default' :
39+ return < Empty type= " default" / > ;
40+ case ' project' :
41+ return < Empty type= " project" description= " 空项目" / > ;
42+ case ' chart' :
43+ return < Empty type= " chart" description= " 图表空数据" / > ;
44+ case ' search' :
45+ return < Empty type= " search" description= " 搜索无数据" / > ;
46+ case ' permission' :
47+ return < Empty type= " permission" description= " 无权限" / > ;
48+ case ' overview' :
49+ return < Empty type= " overview" description= " description" / > ;
50+ default :
51+ return null ;
52+ }
53+ };
3654
3755export default () => {
56+ const [emptyType , setEmptyType ] = useState (' default' );
3857 return (
3958 <>
40- < Empty type = " project " description = " 空项目 " / >
41- < Divider / >
42- < Empty type = " chart " description = " 图表空数据 " / >
43- < Divider / >
44- < Empty type = " search " description = " 搜索无数据 " / >
45- < Divider / >
46- < Empty type = " permission " description = " 无权限 " / >
47- < Divider / >
48- < Empty type = " overview " description = " 概览无数据 " / >
59+ < Space direction = " vertical " style = {{ width : ' 100% ' }} size = { 16 } >
60+ < Radio . Group
61+ defaultValue = " default "
62+ optionType = " button "
63+ options = {options}
64+ onChange = {( e ) => setEmptyType ( e . target . value )}
65+ / >
66+ { getEmpty (emptyType)}
67+ < / Space >
4968 < / >
5069 );
5170};
5271```
5372
5473``` jsx
5574/**
56- * title= "使用自定义图片"
75+ * title: "使用自定义图片"
5776 */
5877import React from ' react' ;
5978import { Empty } from ' dt-react-component' ;
@@ -68,7 +87,7 @@ export default () => {
6887
6988``` jsx
7089/**
71- * title= "更多配置"
90+ * title: "更多配置"
7291 */
7392import React from ' react' ;
7493import { Empty } from ' dt-react-component' ;
@@ -81,7 +100,7 @@ export default () => {
81100 < Empty
82101 height= {60 }
83102 imageStyle= {{ height: 120 }}
84- description= " imageStyle 和 height 共同设置 "
103+ description= " 使用继承自antd的属性imageStyle "
85104 / >
86105 < / >
87106 );
@@ -90,11 +109,12 @@ export default () => {
90109
91110## API
92111
93- | 参数 | 说明 | 类型 | 默认值 |
94- | ------ | ------------------------------------------ | ----------------- | --------- |
95- | type | 默认展示图片的类型 | ` string ` | ` default ` |
96- | image | 自定义图片(设置该参数时,默认的图片不生效) | ` React.ReactNode ` | - |
97- | height | 图片大小(会被 imageStyle 中的 height 覆盖) | ` number ` | ` 80 ` |
112+ | 参数 | 说明 | 类型 | 默认值 |
113+ | ---------- | ------------------------------------------ | --------------------------------------------------------------------------- | --------- |
114+ | type | 默认展示图片的类型 | ` default ` \| ` project ` \| ` chart ` \| ` search ` \| ` permission ` \| ` overview ` | ` default ` |
115+ | height | 图片高度 | ` number ` | 80 |
116+ | image | 自定义图片(设置该参数时,默认的图片不生效) | ` React.ReactNode ` | - |
117+ | imageStyle | 自定义图片样式 | ` React.CSSProperties ` | - |
98118
99119::: info
100120其余属性[ 继承 antd4.x 的 Empty] ( https://ant.design/components/empty-cn/#API )
0 commit comments