1、import xx from yy的方式是静态编译,即编译时加载,要写在文件的最上头,但是import()函数可以实现动态加载,写在任何地方

2、require是动态加载,即运行时加载,理论上可以放在文件的任何位置

3、import是es6语法,目前还是需要babel转换为es5语法执行

4、写法上import要丰富的多。

 

个人建议还是采用import方式

 

参考:

1、https://www.cnblogs.com/liaojie970/p/7376682.html

2、https://www.cnblogs.com/sunshq/p/7922182.html

 

相关文章:

  • 2021-07-02
  • 2022-12-23
  • 2021-12-24
  • 2021-12-05
猜你喜欢
  • 2022-01-31
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案