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
Table of contents 1. Project environment: 2: DNS ...
Table of contents Preface 1. Array traversal meth...
When the user's home directory becomes larger...
This article describes the Mysql self-join query....
It is very important to monitor the operating sta...
A few days ago, when I was working on a requireme...
The default storage directory of mysql is /var/li...
This article example shares the specific code of ...
Step 1: Get the MySQL YUM source Go to the MySQL ...
As a Vue user, it's time to expand React. Fro...
If you have experience in vue2 project developmen...
1. Installation and use First, install it in your...
Table of contents 1. Introduction 2. Customize ta...
Say it in advance On a whim, I want to know what ...
Docker is becoming more and more mature and its f...