@5rabbits/dms 中文文档教程

发布于 5年前 浏览 22 项目主页 更新于 3年前

DMS React Component

Usage

  • Install with yarn add @5rabbits/dms.
  • Install peer dependencies (if you haven't already) yarn add react@^16.0.0 react-dom@^16.0.0 mobx@^3.1.2 mobx-react@^4.3.3. React 15 is also supported.
  • Use the DMS component:
import DMS from '@5rabbits/dms'
import '@5rabbits/dms/dist/dms.css'

<DMS
  apiHost="https://my-api.com"
  apiToken="some-auth-token"
/>

Props

proptypedefaultrequireddescription
apiHoststringyesThe host where all requests will be made.
apiTokenstringyesThe token that will be sent as header Authorization: Bearer TOKEN on every request.
localestring'en'Language to display the component. en and es are supported by default, but you can add other languages using the translations prop.
translationsobjectExtra locales for the component. Use this file as a template and pass the translations as { [locale]: [translations] }.
routerTypememory, browser, hashmemorySpecifies where the component should persist the inner routing.
defaultRoutestring'/'(memory router only) The initial route the component will render. At the moment you can use:
  • /
  • /files (alias of /)
  • /recent
  • /deleted
  • /(files|recent|deleted)/:itemID (the first segments is used to highlight the corresponding sidebar section)
onRouteChangefuncCallback that will be invoked every time the internal route changes. The first argument will be the new route string.
baseRoutestring(browser and hash routers only) The base url segment for browser based routes.
onErrorfunc(React 16 only) Callback that will be invoked if the DMS component crashes and recovers itself. The first argument is the exception and the second one is the React components stack. This is provided for error tracking purposes.

DMS React Component

Usage

  • Install with yarn add @5rabbits/dms.
  • Install peer dependencies (if you haven't already) yarn add react@^16.0.0 react-dom@^16.0.0 mobx@^3.1.2 mobx-react@^4.3.3. React 15 is also supported.
  • Use the DMS component:
import DMS from '@5rabbits/dms'
import '@5rabbits/dms/dist/dms.css'

<DMS
  apiHost="https://my-api.com"
  apiToken="some-auth-token"
/>

Props

proptypedefaultrequireddescription
apiHoststringyesThe host where all requests will be made.
apiTokenstringyesThe token that will be sent as header Authorization: Bearer TOKEN on every request.
localestring'en'Language to display the component. en and es are supported by default, but you can add other languages using the translations prop.
translationsobjectExtra locales for the component. Use this file as a template and pass the translations as { [locale]: [translations] }.
routerTypememory, browser, hashmemorySpecifies where the component should persist the inner routing.
defaultRoutestring'/'(memory router only) The initial route the component will render. At the moment you can use:
  • /
  • /files (alias of /)
  • /recent
  • /deleted
  • /(files|recent|deleted)/:itemID (the first segments is used to highlight the corresponding sidebar section)
onRouteChangefuncCallback that will be invoked every time the internal route changes. The first argument will be the new route string.
baseRoutestring(browser and hash routers only) The base url segment for browser based routes.
onErrorfunc(React 16 only) Callback that will be invoked if the DMS component crashes and recovers itself. The first argument is the exception and the second one is the React components stack. This is provided for error tracking purposes.
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文