Vue loading improves user experience as needed, and vue loading improves user experience
Official Vue documentation asynchronous components:
In large applications, we may need to split the applications into multiple small modules and download them from the server as needed. To make things easier, Vue. js allows you to define a component as a factory function and dynamically parse the definition of the component. Vue. js only triggers factory functions when the component needs to be rendered, and caches the results for subsequent re-rendering.
Source image from http://www.cnblogs.com/Kummy/p/5254754.html
Vue load related articles as needed:
1: http://cn.vuejs.org/guide/components.html#
2: http://webpack.github.io/docs/code-splitting.html
-----------------------------------------------------------
Today, we provide some practical project experience solutions for loading on demand (that is, loading without request:
Vue On-Demand Loading Scheme: require ([asynchronously loaded components], resolve)
Angular On-Demand Loading Scheme: $ ocLazyLoad
Vue On-Demand Loading Scheme: require ([asynchronously loaded components], resolve)
Two steps are required to complete on-demand loading.
Step 1: make configuration changes for webpack. js,
Step 2: Modify the router route, mainly the component ,.
Step 3: run the npm run build package command. You can see that the chunks folder generates many small chunk files, that is, the vue component page,
Angular load related articles as needed:
1: http://www.alloyteam.com/2016/03/es6-front-end-developers-will-have-to-know-the-top-ten-properties/
2: http://www.mamicode.com/info-detail-407754.html
Angular load as needed: $ ocLazyLoad
Three steps are required to implement the On-Demand Loading Scheme.
Step 2: bower install oclazyload
Step 2: $ ocLazyLoad encapsulation:
Step 2: configure the ui-router route:
This solution is done, and the template and controller files are loaded as needed. Access the page to see the effect.
Effect Gif Demo: