当前位置:网站首页>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>
边栏推荐
- 直击“三夏”生产:丰收喜报频传 夏播紧锣密鼓
- Antdb database online training has started! More flexible, professional and rich
- 01---两列波在相遇处发生干涉的条件
- TDengine可通过数据同步工具 DataX读写
- 应用实践 | 海量数据,秒级分析!Flink+Doris 构建实时数仓方案
- Functional analysis of ebpf sockops
- suspense组件和异步组件
- ping: www.baidu. Com: unknown name or service
- LeetCode-513. 找树左下角的值
- ST表+二分
猜你喜欢

Intelligent fish tank control system based on STM32 under Internet of things

推荐模型之多任务模型:ESMM、MMOE

Memcached comprehensive analysis – 3 Deletion mechanism and development direction of memcached

VSCode无网环境快速迁移开发环境(VIP典藏版)
![[theory] deep learning in the covid-19 epic: a deep model for urban traffic revitalization index](/img/d9/f5461a81a343f3c3ca01876e423fa2.png)
[theory] deep learning in the covid-19 epic: a deep model for urban traffic revitalization index

Datakit 代理实现局域网数据统一汇聚

Why are life science enterprises on the cloud in succession?

socket done

Pattern recognition - 1 Bayesian decision theory_ P1

Antdb database online training has started! More flexible, professional and rich
随机推荐
直击“三夏”生产:丰收喜报频传 夏播紧锣密鼓
BBR bandwidth per second conversion logic
03---增反膜
leetcode:1504. 统计全 1 子矩形的个数
TCP Jprobe utilization problem location
基于ASP.NET开发的固定资产管理系统源码 企业固定资产管理系统源码
Unity关于本地坐标和世界坐标之间的转换
机器学习:线性回归
TCP_ Nodelay and TCP_ CORK
Slider控制Animator动画播放进度
02---纵波不可能产生的现象
leetcode_1365
WMI and PowerShell get TCP connection list
Volcano becomes spark default batch scheduler
Remove the screen recording reminder (seven cattle cloud demo)
MySQL optimizes query speed
力扣每日一题-第25天-496.下一个更大元素Ⅰ
Advanced secret of xtransfer technology newcomers: the treasure you can't miss mentor
Slider controls the playback progress of animator animation
Multiplexer select