In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces vue how to use dynamic components to lazily load components, the article is very detailed, has a certain reference value, interested friends must read it!
Use dynamic components to lazily load components
Components are loaded synchronously, but when there is a lot of content on the page, some components do not need to be loaded from the beginning, such as pop-up components, these can be loaded out with dynamic components, and then loaded out after the user has performed certain operations, which can improve the performance of the main module loading. In Vue, component dynamic components can be used to determine which component is rendered according to the value of is.
Main page Click recording component 1 Click recording component 2 import {Component, Vue} from 'vue-property-decorator';@Component ({}) export default class AsyncComponent extends Vue {public child1:Component = null; public child2:Component = null; handleClick1 () {this.child1 = require ('. / child1'). Default;} handleClick2 () {this.child2 = require ('. / child2'). Default;}}
In the sample code, the component is loaded only when clicked. Component can also cooperate with v-show to control display and hiding, so that the component will only mounted once to optimize performance.
These are all the contents of the article "how vue uses dynamic components to load components lazily". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.