Vue loading improves user experience as needed, and vue loading improves user experience

Source: Internet
Author: User

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:

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.