提交 39f7830d 编写于 作者: J jim

update Authorized doc

上级 365ad517
......@@ -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 Havepermission = () => {
const havePermission = () => {
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,
);
```
......@@ -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.
先完成此消息的编辑!
想要评论请 注册