search

Home  >  Q&A  >  body text

html5 - If the vue SPA project has too many components, wouldn’t the packaged files be too large?

Isn’t it very slow when loading for the first time? Is my question reasonable? How to deal with it?

伊谢尔伦伊谢尔伦2816 days ago496

reply all(4)I'll reply

  • 天蓬老师

    天蓬老师2017-05-16 13:44:05

    There are too many components, so routing is usually added, right? Then just use lazy loading in vue-router...
    https://router.vuejs.org/zh-c...

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-05-16 13:44:05

    Can be loaded asynchronously. For example, if I have 10 pages, the total package size may be 10M, which is definitely too large. Then I can package the home page and load the others asynchronously, loading which one is accessed. This will make it faster to open for the first time.

    You can see vue-router documentation for lazy loading https://router.vuejs.org/zh-c...

    reply
    0
  • 高洛峰

    高洛峰2017-05-16 13:44:05

    Added that vue2 also has a server-side rendering solution that can solve performance problems

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-05-16 13:44:05

    Lazy loading can be achieved through vue-router and webpack

    reply
    0
  • Cancelreply