Ant-design-pro: 🧐[问题]V5 app.tsx中responseInterceptor中无法使用useIntl()

Created on 27 Aug 2020  ·  2Comments  ·  Source: ant-design/ant-design-pro

国际化在app.tsx中做返回数据统一拦截,发现用不了useIntl()
notification.info({
description: useIntl().formatMessage({ id: 'error' }),
message: useIntl().formatMessage({ id: 'error' }),
});
image

image

🕵🏻‍♀️ question

Most helpful comment

这么用:

import { getIntl } from 'umi';

// 必须在函数里用以下语句
const intl = getIntl()

当初我也是被坑了好久才找到的……

All 2 comments

这么用:

import { getIntl } from 'umi';

// 必须在函数里用以下语句
const intl = getIntl()

当初我也是被坑了好久才找到的……

这么用:

import { getIntl } from 'umi';

// 必须在函数里用以下语句
const intl = getIntl()

当初我也是被坑了好久才找到的……

哎呀,真的是太谢谢了,解决了。再问个问题,你做的多语言是从后端获取的吗?

Was this page helpful?
0 / 5 - 0 ratings