dispatchEvent 时间触发器

const[]=this.props

  1. render() {
  2. const {
  3. children,
  4. location: { pathname },
  5. breadcrumbNameMap,
  6. } = this.props;}
  1. const {
  2. dispatch,
  3. route: { routes, authority },
  4. } = this.props;
  5. dispatch({
  6. type: 'menu/getMenuData',
  7. payload: { routes, authority },
  8. });

const RegisterResult = ({ location }) => ()

  1. const RegisterResult = ({ location }) => (
  2. <Result
  3. className={styles.registerResult}
  4. type="success"
  5. title={
  6. <div className={styles.title}>
  7. <FormattedMessage
  8. id="app.register-result.msg"
  9. values={{ email: location.state ? location.state.account : 'AntDesign@example.com' }}
  10. />
  11. </div>
  12. }
  13. description={formatMessage({ id: 'app.register-result.activation-email' })}
  14. actions={actions}
  15. style={{ marginTop: 56 }}
  16. />
  17. );

面包屑breadcrumb导航

首页/表单/高级表单 (src/components/PageHeaderWrapper/breadcrumb.js)
作用:快速返回上一级

const extraBreadcrumbItems = pathSnippets.map(url => {)

  1. const extraBreadcrumbItems = pathSnippets.map(url => {
  2. const currentBreadcrumb = getBreadcrumb(breadcrumbNameMap, url);
  3. if (currentBreadcrumb.inherited) {
  4. return null;
  5. }
  6. const name = renderItemLocal(currentBreadcrumb);
  7. const { hideInBreadcrumb } = currentBreadcrumb;
  8. return name && !hideInBreadcrumb
  9. ? {
  10. path: url,
  11. breadcrumbName: name,
  12. }
  13. : null;
  14. });

for循环

  1. function getRenderArr(routes) {
  2. let renderArr = [];
  3. renderArr.push(routes[0]);
  4. for (let i = 1; i < routes.length; i += 1) {
  5. // 去重
  6. renderArr = renderArr.filter(item => getRelation(item, routes[i]) !== 1);
  7. // 是否包含
  8. const isAdd = renderArr.every(item => getRelation(item, routes[i]) === 3);
  9. if (isAdd) {
  10. renderArr.push(routes[i]);
  11. }
  12. }
  13. return renderArr;
  14. }

math/number

.isNaN是判断是否是一个数
Math.floor:判断一个最接近val的商。
val的解释(method) Math.floor(x: number): number
Returns the greatest integer less than or equal to its numeric argument.
@param x — A numeric expression.

  1. export function formatWan(val) {
  2. const v = val * 1;
  3. if (!v || Number.isNaN(v)) return '';
  4. let result = val;
  5. if (val > 10000) {
  6. result = Math.floor(val / 10000);
  7. result = (
  8. <span>
  9. {result}
  10. <span
  11. style={{
  12. position: 'relative',
  13. top: -2,
  14. fontSize: 14,
  15. fontStyle: 'normal',
  16. marginLeft: 2,
  17. }}
  18. >
  19. </span>
  20. </span>
  21. );
  22. }
  23. return result;}

正则表达式

  1. const reg = /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/;

effects参数

  • put 用于触发action
    1. yield put({type: 'user/changeNotifyCount',
    2. payload: {totalCount: data.length,unreadCount,});
  • call 用于调用异步逻辑,适用于promise
    1. const data = yield call(queryNotices);
  • select 从state获取数据
    1. const unreadCount = yield select(
    2. state => state.global.notices.filter(item => !item.read).length);

屏幕尺寸布局

col-lg一般用于大屏设备,
(min-width:1200px);
col-md一般用于中屏设备,
(min-width:992px);
col-sm一般用于小屏设备,
(min-width:768px);
col-xs用于超小型设备,
(max-width:768px);
col-xl一般用于超超小屏设备,
(min-width:768px);

业务图标

mock

mock 文件夹下的文件即 mock 文件,文件导出接口定义,支持基于 require 动态分析的实时刷新,支持 ES6 语法,以及友好的出错提示

模拟网络延迟

国际化