Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

vue-cli3 如何修改Prefetch选项?

https://cli.vuejs.org/zh/guide/html-and-static-assets.html#prefetch

在vue-cli3脚手架搭建的vue项目里,配置vue路由懒加载并不会生效,启动项目还是会加载全部组件。这是因为vue-cli3会默认给async chunk组件标记 prefetch 预加载。被标记为prefetch的资源,将会被浏览器在空闲时间加载。

但有些场景(比如移动端流量敏感),并不希望所有组件都被预加载。vue-cli3文档提供了设置prefetch的方法,但是写的很粗略。如下:
image.png
第二个方法-修改选项,是怎么修改的?我直接复制没有生效,也找不到更详细的文档。
暂时采用第一种方法,移除prefetch插件再给需要预加载的路由单独添加魔法注释。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...