当前位置:网站首页>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
Suspense
Package components , And configureddefault
Andfallback
<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>
边栏推荐
- RFC 793 why to send reset and when to send reset
- 02---纵波不可能产生的现象
- [featured] how do you design unified login with multiple accounts?
- 【吴恩达笔记】机器学习基础
- Unity about conversion between local and world coordinates
- Visit Amazon memorydb and build your own redis memory database
- VirtualBox virtual machine installation win10 Enterprise Edition
- TCP specifies the source port
- STL+树
- 【论】A deep-learning model for urban traffic flow prediction with traffic events mined from twitter
猜你喜欢
随机推荐
Installing Oracle without graphical interface in virtual machine centos7 (nanny level installation)
Tso hardware sharding is a header copy problem
Pattern recognition - 0 introduction
TCP_ Nodelay and TCP_ CORK
Wireshark packet capturing skills summarized by myself
The most important thing at present
Analyse complète Memcached – 2. Comprendre le stockage de mémoire pour Memcached
Blender's landscape
[camera Foundation (II)] camera driving principle and Development & v4l2 subsystem driving architecture
将二维数组方阵顺时针旋转90°
CondaValueError: The target prefix is the base prefix. Aborting.
Memcached comprehensive analysis – 3 Deletion mechanism and development direction of memcached
01---两列波在相遇处发生干涉的条件
SAP接口debug设置外部断点
Slider控制Animator动画播放进度
#国企央企结构化面试#国企就业#墨斗互动就业服务管家
socket(1)
Memcached comprehensive analysis – 5 Memcached applications and compatible programs
【Camera基础(二)】摄像头驱动原理和开发&&V4L2子系统驱动架构
Shengzhe technology AI intelligent drowning prevention service launched