异步组件
<template>
<Suspense v-if="!routerLoading">
<template #default>
<AsyncComp />
</template>
<template #fallback>
<div class="loading-container">
<div class="loading-content">
<div class="loading-text">加载中...</div>
<div class="loading-spinner"></div>
</div>
</div>
</template>
</Suspense>
</template>
<script>
const AsyncComp = defineAsyncComponent(() => {
return new Promise(resolve => {
setTimeout(() => {
resolve({
render() {
return "hello world";
}
})
},2000);
});
})
</script>
标签:AsyncComp,vue,return,性能,resolve,优化
From: https://www.cnblogs.com/zhuxiang1633/p/18676415