You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
602 B
31 lines
602 B
<template> |
|
<div className="app"> |
|
<h3>我是app组件</h3> |
|
<Suspense> |
|
<template v-slot:default> |
|
<Child/> |
|
</template> |
|
<template v-slot:fallback> |
|
<h3>加载中</h3> |
|
</template> |
|
</Suspense> |
|
</div> |
|
</template> |
|
|
|
<script> |
|
// import child from "@/components/Child"; // 静态引入 |
|
import {defineAsyncComponent} from 'vue'; |
|
|
|
const Child = defineAsyncComponent(() => import('./components/Child.vue')) // 动态引用 |
|
export default { |
|
name: 'App', |
|
components: {Child}, |
|
} |
|
</script> |
|
|
|
<style> |
|
.app { |
|
background-color: gray; |
|
padding: 10px; |
|
} |
|
</style> |