import语句写在const语句上面即可

react引入报错:Import in body of module; reorder to top import/first
一、问题情形
想动态引入模块:

const Demo = React.lazy(() => import('./jsTest/demo'));

使用React.lazy报错Import in body of module; reorder to top  import/first

结果报错,错误提示如下:

使用React.lazy报错Import in body of module; reorder to top  import/first

 

 

二、解决方法
将import语句写在const语句上面即可:

使用React.lazy报错Import in body of module; reorder to top  import/first

 

 

报错消失了,页面可正常显示

来自:https://blog.csdn.net/weixin_42260975/article/details/106850524

相关文章:

  • 2021-10-17
  • 2021-06-02
  • 2022-12-23
  • 2022-01-15
  • 2022-12-23
猜你喜欢
  • 2021-07-18
  • 2022-12-23
  • 2022-12-23
  • 2021-04-10
  • 2021-04-12
  • 2021-10-17
  • 2021-11-27
相关资源
相似解决方案