Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
钟摆人-Puppet゜
ant-design-pro
提交
39f7830d
A
ant-design-pro
项目概览
钟摆人-Puppet゜
/
ant-design-pro
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
ant-design-pro
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
39f7830d
编写于
1月 09, 2018
作者:
J
jim
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update Authorized doc
上级
365ad517
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
17 addition
and
59 deletion
+17
-59
src/components/Authorized/demo/basic.md
src/components/Authorized/demo/basic.md
+16
-58
src/components/Authorized/index.md
src/components/Authorized/index.md
+1
-1
未找到文件。
src/components/Authorized/demo/basic.md
浏览文件 @
39f7830d
...
...
@@ -5,25 +5,6 @@ title:
en-US
:
Basic
---
Simplest of usage.
```
jsx
import
RenderAuthorized
from
'
ant-design-pro/lib/Authorized
'
;
import
{
Alert
}
from
'
antd
'
;
const
Authorized
=
RenderAuthorized
(
'
user
'
);
const
noMatch
=
<
Alert
message
=
"No permission."
type
=
"error"
showIcon
/>;
ReactDOM
.
render
(
<
Authorized
authority
=
"admin"
noMatch
=
{
noMatch
}
>
<
Alert
message
=
"Passed!"
type
=
"success"
showIcon
/>
</
Authorized
>
mountNode
,
);
```
user Array
```
jsx
import
RenderAuthorized
from
'
ant-design-pro/lib/Authorized
'
;
import
{
Alert
}
from
'
antd
'
;
...
...
@@ -31,54 +12,31 @@ import { Alert } from 'antd';
const
Authorized
=
RenderAuthorized
(
'
user
'
);
const
noMatch
=
<
Alert
message
=
"No permission."
type
=
"error"
showIcon
/>;
ReactDOM
.
render
(
<
Authorized
authority
=
{
[
'
user
'
,
'
admin
'
]
}
noMatch
=
{
noMatch
}
>
<
Alert
message
=
"Passed!"
type
=
"success"
showIcon
/>
</
Authorized
>
mountNode
,
);
```
user Funtion
```
jsx
import
RenderAuthorized
from
'
ant-design-pro/lib/Authorized
'
;
import
{
Alert
}
from
'
antd
'
;
const
Authorized
=
RenderAuthorized
(
'
user
'
);
const
noMatch
=
<
Alert
message
=
"No permission."
type
=
"error"
showIcon
/>;
const
Havep
ermission
=
()
=>
{
const
haveP
ermission
=
()
=>
{
return
false
;
};
ReactDOM
.
render
(
<
Authorized
authority
=
{
Havepermission
}
noMatch
=
{
noMatch
}
>
<
Alert
message
=
"Passed!"
type
=
"success"
showIcon
/>
</
Authorized
>
mountNode
,
);
```
user Promise
```
jsx
import
RenderAuthorized
from
'
ant-design-pro/lib/Authorized
'
;
import
{
Alert
}
from
'
antd
'
;
const
Authorized
=
RenderAuthorized
(
'
user
'
);
const
noMatch
=
<
Alert
message
=
"No permission."
type
=
"error"
showIcon
/>;
const
Havepermission
=
new
Promise
((
reslove
,
reject
)
=>
{
const
havePermissionAsync
=
new
Promise
((
resolve
,
reject
)
=>
{
// Call reslove on behalf of passed
setTimeout
(()
=>
reslove
(),
1000
)
});
ReactDOM
.
render
(
<
Authorized
authority
=
{
Havepermission
}
noMatch
=
{
noMatch
}
>
<
Alert
message
=
"Passed!"
type
=
"success"
showIcon
/>
</
Authorized
>
<
div
>
<
Authorized
authority
=
"admin"
noMatch
=
{
noMatch
}
>
<
Alert
message
=
"user Passed!"
type
=
"success"
showIcon
/>
</
Authorized
>
<
Authorized
authority
=
{
[
'
user
'
,
'
admin
'
]
}
noMatch
=
{
noMatch
}
>
<
Alert
message
=
"Use Array as a parameter passed!"
type
=
"success"
showIcon
/>
</
Authorized
>
<
Authorized
authority
=
{
Havepermission
}
noMatch
=
{
noMatch
}
>
<
Alert
message
=
"Use function as a parameter passed!"
type
=
"success"
showIcon
/>
</
Authorized
>
<
Authorized
authority
=
{
havePermissionAsync
}
noMatch
=
{
noMatch
}
>
<
Alert
message
=
"Use Promise as a parameter passed!"
type
=
"success"
showIcon
/>
</
Authorized
>
</
div
>
mountNode
,
);
```
src/components/Authorized/index.md
浏览文件 @
39f7830d
...
...
@@ -48,7 +48,7 @@ order: 15
### Authorized.check
函数形式的 Authorized,用于某些不能被 HOC 包裹的组件。
`Authorized.check(authority, target, Exception)`
注意
:传入一个Promise时 无论正确还是错误返回的都是一个ReactNode.
注意
:传入一个 Promise 时,无论正确还是错误返回的都是一个 ReactClass。
| 参数 | 说明 | 类型 | 默认值 |
|----------|------------------------------------------|-------------|-------|
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录