当前位置:网站首页>Suspend component and asynchronous component
Suspend component and asynchronous component
2022-06-24 21:51:00 【aliven1】
Render some extra content while waiting for asynchronous components , Let the application have a better user experience
Use steps :
Introduce components asynchronously , Use defineAsyncComponent Define asynchronous components
import { defineAsyncComponent} from 'vue' const Child = defineAsyncComponent(()=>import('./components/Child.vue'))Use
SuspensePackage components , And configureddefaultAndfallback<template> <div class="app"> <h3> I am a App Components </h3> <Suspense> <template v-slot:default> <Child/> </template> <template v-slot:fallback> <h3> Loading .....</h3> </template> </Suspense> </div> </template>- Asynchronous component child in setup Can be defined as an asynchronous function , Using asynchronous components requires Suspense The parcel
<template>
<div class="child">
<h3> I am a Child Components </h3>
{
{
sum}}
</div>
</template>
<script>
import {
ref} from 'vue'
export default {
name:'Child',
async setup(){
let sum = ref(0)
let p = new Promise((resolve,reject)=>{
setTimeout(()=>{
resolve({
sum})
},1000)
})
return await p
}
}
</script>
边栏推荐
- dp问题集
- 虚拟机CentOS7中无图形界面安装Oracle(保姆级安装)
- socket(2)
- Datakit 代理实现局域网数据统一汇聚
- Blender's simple skills - array, rotation, array and curve
- 力扣每日一题-第26天-496.下一个更大元素Ⅰ
- 手动事务的几个类
- 即构「畅直播」上线!提供全链路升级的一站式直播服务
- Byte software testing basin friends, you can change jobs. Is this still the byte you are thinking about?
- 【Camera基础(一)】Camera摄像头工作原理及整机架构
猜你喜欢

C语言实现DNS请求器

关于Unity中的transform.InverseTransformPoint, transform.InverseTransofrmDirection

About transform InverseTransformPoint, transform. InverseTransofrmDirection

Pattern recognition - 1 Bayesian decision theory_ P1

memcached完全剖析–1. memcached的基础
![[featured] how do you design unified login with multiple accounts?](/img/df/9b4fc11a6971ebe8162ae84250a782.png)
[featured] how do you design unified login with multiple accounts?

(to be added) games101 job 7 improvement - knowledge you need to know to realize micro surface model

Understanding openstack network

memcached全面剖析–2. 理解memcached的內存存儲

Datakit 代理实现局域网数据统一汇聚
随机推荐
图的邻接表存储 数组实现
滤波数据分析
Tournament sort
力扣每日一题-第25天-496.下一个更大元素Ⅰ
how to install clustershell
Decoration home page custom full screen video playback effect GIF dynamic picture production video tutorial playback code operation settings full screen center Alibaba international station
Network layer & IP
ST表+二分
Debugging Analysis of Kernel panics and Kernel oopses using System Map
Advanced secret of xtransfer technology newcomers: the treasure you can't miss mentor
188. the best time to buy and sell stocks IV
双链表实现
【吴恩达笔记】机器学习基础
socket(1)
Memcached comprehensive analysis – 3 Deletion mechanism and development direction of memcached
BPF_ PROG_ TYPE_ SOCKET_ Filter function implementation
Blender's simple skills - array, rotation, array and curve
socket done
C语言-关键字1
MySQL optimizes query speed