diff --git a/src/components/Authorized/demo/basic.md b/src/components/Authorized/demo/basic.md index c8133106adaa9ce0dbcc997be9969e147f77b9e0..a18633c4492dea9c1a5fdbb5f4942b8da5c64911 100644 --- a/src/components/Authorized/demo/basic.md +++ b/src/components/Authorized/demo/basic.md @@ -7,16 +7,78 @@ title: Simplest of usage. -````jsx +```jsx import RenderAuthorized from 'ant-design-pro/lib/Authorized'; import { Alert } from 'antd'; const Authorized = RenderAuthorized('user'); -const noMatch = +const noMatch = ; ReactDOM.render( - + -, mountNode); -```` + mountNode, +); +``` + +user Array + +```jsx +import RenderAuthorized from 'ant-design-pro/lib/Authorized'; +import { Alert } from 'antd'; + +const Authorized = RenderAuthorized('user'); +const noMatch = ; + +ReactDOM.render( + + + + mountNode, +); +``` + +user Funtion + +```jsx +import RenderAuthorized from 'ant-design-pro/lib/Authorized'; +import { Alert } from 'antd'; + +const Authorized = RenderAuthorized('user'); +const noMatch = ; + +const Havepermission = () => { + return false; +}; + +ReactDOM.render( + + + + mountNode, +); +``` + + +user Promise + +```jsx +import RenderAuthorized from 'ant-design-pro/lib/Authorized'; +import { Alert } from 'antd'; + +const Authorized = RenderAuthorized('user'); +const noMatch = ; + +const Havepermission = new Promise((reslove,reject)=>{ + // Call reslove on behalf of passed + setTimeout(()=>reslove(),1000) +}); + +ReactDOM.render( + + + + mountNode, +); +``` diff --git a/src/components/Authorized/index.md b/src/components/Authorized/index.md index f4015e16ede531170a3e0884554f1b3392a5d82a..c53be7b83722c5a0a9ae36fec98ee098a9f36da5 100644 --- a/src/components/Authorized/index.md +++ b/src/components/Authorized/index.md @@ -47,7 +47,8 @@ order: 15 ### Authorized.check -函数形式的 Authorized,用于某些不能被 HOC 包裹的组件。 `Authorized.check(authority, target, Exception)` +函数形式的 Authorized,用于某些不能被 HOC 包裹的组件。 `Authorized.check(authority, target, Exception)` +注意:传入一个Promise时 无论正确还是错误返回的都是一个ReactNode. | 参数 | 说明 | 类型 | 默认值 | |----------|------------------------------------------|-------------|-------|