5 changed files with 68 additions and 75 deletions
@ -0,0 +1,23 @@ |
|||||
|
--- |
||||
|
order: 1 |
||||
|
title: |
||||
|
zh-CN: 使用数组作为参数 |
||||
|
en-US: Use Array as a parameter |
||||
|
--- |
||||
|
|
||||
|
Use Array as a parameter |
||||
|
|
||||
|
```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={['user', 'admin']} noMatch={noMatch}> |
||||
|
<Alert message="Use Array as a parameter passed!" type="success" showIcon /> |
||||
|
</Authorized>, |
||||
|
mountNode, |
||||
|
); |
||||
|
``` |
||||
@ -0,0 +1,31 @@ |
|||||
|
--- |
||||
|
order: 2 |
||||
|
title: |
||||
|
zh-CN: 使用方法作为参数 |
||||
|
en-US: Use function as a parameter |
||||
|
--- |
||||
|
|
||||
|
Use Function as a parameter |
||||
|
|
||||
|
```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 = () => { |
||||
|
return false; |
||||
|
}; |
||||
|
|
||||
|
ReactDOM.render( |
||||
|
<Authorized authority={havePermission} noMatch={noMatch}> |
||||
|
<Alert |
||||
|
message="Use Function as a parameter passed!" |
||||
|
type="success" |
||||
|
showIcon |
||||
|
/> |
||||
|
</Authorized>, |
||||
|
mountNode, |
||||
|
); |
||||
|
``` |
||||
Loading…
Reference in new issue