Umi: 使用了layout配置后控制台弹出很多警告⚠️

Created on 23 Sep 2020  ·  5Comments  ·  Source: umijs/umi

What happens?

新建项目 umirc.ts 中开启 layout:{}
控制台启动后会抛出很多警告,但是能正常使用

 WARNING  Compiled with 8 warnings                                                                                                     19:49:43

 warning  in ./src/.umi/plugin-layout/layout/layout/renderRightContent.tsx

"export 'SelectLang' was not found in 'umi'

 warning  in ./src/.umi/plugin-layout/layout/layout/renderRightContent.tsx

"export 'SelectLang' was not found in 'umi'

 warning  in ./src/.umi/plugin-layout/layout/utils/intl.ts

"export 'getLocale' was not found in 'umi'

 warning  in ./src/.umi/plugin-layout/layout/layout/index.tsx

"export 'useIntl' was not found in 'umi'

 warning  in ./src/.umi/plugin-layout/layout/layout/index.tsx

"export 'useIntl' was not found in 'umi'

 warning  in ./src/.umi/plugin-layout/layout/utils/intl.ts

"export 'useIntl' was not found in 'umi'

期待结果

去除掉这些不影响结果的警告消息

  • Umi 版本:3
  • Node 版本
  • 操作系统

Most helpful comment

我的解决办法是增加: locale: {}

// .umirc.ts
export default defineConfig({
  ...
  layout: {
    locale: false,
  },
  locale: {},
})

All 5 comments

貌似是默认开启了多语言的功能,然后又没有相应的配置,感觉像是布局插件的问题

  1. 麻烦阅读 https://umijs.org/zh-CN/plugins/preset-react
  2. 检查 package.json 是否包含相应插件
    image

@gujintao1900

是有的,但是还是有提示

我是第一次使用umi,我按照官网的快速上手来走一遍,也发现了这个问题,另外 @ant-design/pro-layout 好像是一开始就有的,并不需要自己再去安装。这初体验确实太影响第一印象了。

我的解决办法是增加: locale: {}

// .umirc.ts
export default defineConfig({
  ...
  layout: {
    locale: false,
  },
  locale: {},
})
Was this page helpful?
0 / 5 - 0 ratings