关于组件蓝加载的问题,请老师帮忙看看

来源:8-1 懒加载性能优化

也许是这样

2019-05-25

// 配置组件懒加载
import(’…/My/My’).then((component)=>{
console.log(component);
})
老师,我根据您的写的,写的一抹一样,但我的浏览器报错了。报的错误是:Uncaught Error: Module parse failed: ‘import’ and ‘export’ may only appear at the top level (52:8)
You may need an appropriate loader to handle this file type.
说什么import必须在开头,但您写的就没事啊,为啥我写的就不行呢

写回答

1回答

吕小鸣

2019-05-25

同学你好,出错的原因可能是你的node_modules里面的版本和视频里的代码不兼容的问题。
建议你可以把git上源码里的package.json下载下来,删除本地的node_modules,然后在npm install一下重新生成一次哈

0
2
也许是这样
问题解决了,谢谢老师。 貌似是版本的问题。
2019-05-25
共2条回复

移动Web App开发之实战美团外卖

运用React全家桶技术,从0到1学习全面的移动 Web APP 开发技术。

389 学习 · 235 问题

查看课程