Vue-router routing lazy loading (solve the slow loading of the vue project for the first time)

Vue-router routing lazy loading (solve the slow loading of the vue project for the first time)

Lazy loading: ----------------------------------------------- -----?

    It is also called lazy loading, that is, it is loaded when it is needed, and it is loaded as needed.

Why do you need lazy loading?

    For a single-page application like Vue, if there is no lazy loading of the application, the file packaged with webpack will be abnormally large, resulting in too much content to be loaded when entering the home page, and the time will be too long, and it will be a long white space first. Even if loading is done, it is not conducive to the user experience, but using lazy loading can divide the page and load the page when needed, which can effectively share the loading pressure of the home page and reduce the loading time of the home page.

    Simply put: entering the home page does not require loading too many resources at one time, which will cause the time to take too long! ! !

How to achieve?

    Lazy loading writing:

        

  Non-lazy-loaded routing configuration:

        

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325170846&siteId=291194637