Create a Vite project Performance determines success or failure; Vite is indeed fast; Creating ComponentsCreate a new directory called pages, and under pages, create a new directory called contents. Under contents, you can create a specific component directory page. At this time, the directory structure is as follows: App.vue <template> <p @click="onChangeContents('./pages/contents/gp/gp.vue')">Guo Pei</p> <p @click="onChangeContents('./pages/contents/systemManges/xtcs.vue')">System parameters</p> <p>{{currentTabComponent}}</p> <!-- <Suspense> --> <component :is="DefineAsyncComponent({ //Factory function loader: Modeuls[currentTabComponent], // // Default value: Infinity (i.e. never time out, unit: ms) timeout: 3000, })"></component> <!-- </Suspense> --> </template> <script lang="ts"> import { defineComponent, defineAsyncComponent, reactive, ref } from 'vue' export default defineComponent({ name: 'App', setup() { //vite loads all modules of the specified path const Modeuls = import.meta.glob('./pages/contents/*/*'); const onChangeContents = function(URL) { currentTabComponent.value = URL; console.log(currentTabComponent) } let currentTabComponent = ref('./pages/contents/systemManges/xtcs.vue'); const DefineAsyncComponent = defineAsyncComponent; return { DefineAsyncComponent, currentTabComponent, onChangeContents, Modeuls } }, }) </script> This is the end of this article about vue3.0+vite2 to implement dynamic asynchronous component lazy loading. For more related vue3.0+vite2 dynamic asynchronous lazy loading content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Implementation example of nginx access control
>>: MySQL slow_log table cannot be modified to innodb engine detailed explanation
Demand scenario: The boss asked me to use the cra...
Preface To help ensure that your web pages have a ...
Apple Mug Icons and Extras HD StorageBox – add on...
Table of contents Overview Problem Description Ci...
An index is a sorted data structure! The fields t...
In MySQL database operations, we always hope to a...
Original address: https://blog.csdn.net/m0_465798...
Table of contents 1. Component Organization 2. Co...
Everyone knows that images on web pages are genera...
In the latest version of WIN10, Microsoft introdu...
This article shares with you how to connect pytho...
tomcat server configuration When everyone is lear...
Anyone who has used the Linux system should know ...
Tag type (display mode) HTML tags are generally d...
This article example shares the specific code of ...