Umi Max 国际化使用

ReactElement内使用

import { FormattedMessage } from '@umijs/max';
<FormattedMessage id="project.tunnel.label" />

函数内使用

import { useIntl } from '@umijs/max';
const AppLayout = ({ children, version }: any) => {
  const intl = useIntl();
  const msg = intl.formatMessage({ id: 'project.menu.draw.index' });
}

外部文件使用

import { getIntl, getLocale } from '@umijs/max';
const intl = getIntl(getLocale());
message.error(intl.formatMessage({ id: error.response.data.message}));

injectIntl还没遇到需要的地方,暂时不了解用法。

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注