国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

學(xué)習(xí)如何在Vue 3中實(shí)現(xiàn)動態(tài)組件導(dǎo)入
P粉253800312
P粉253800312 2023-08-24 16:00:23
0
1
777
<p>根據(jù)這篇文章,我想要將組件動態(tài)地導(dǎo)入到我的Vue 3應(yīng)用程序中。視圖的代碼如下:</p> <pre class="brush:php;toolbar:false;"><template> <div class="page"> <latest-box v-if="showLatestBox" /> </div> </template> <script> // @ 是 /src 的別名 // 這種方式有效 //import LatestBox from '@/components/LatestBox.vue' export default { name: 'Page 1', data() { return { showLatestBox: true, } }, components: { LatestBox: () => import('@/components/LatestBox.vue') // 這種方式無效 } } </script></pre> <p>代碼沒有報(bào)錯,但是我在頁面上看不到組件。如果我使用第一種導(dǎo)入方式,它可以工作。我漏掉了什么嗎?</p>
P粉253800312
P粉253800312

全部回復(fù)(1)
P粉970736384

在Vue 3中,你需要使用defineAsyncComponent來懶加載組件

import { defineAsyncComponent } from 'vue'
...
    components: {
        LatestBox: defineAsyncComponent(() => import('@/components/LatestBox.vue'))
    }

https://v3-migration.vuejs.org/breaking-changes/async-components.html#overview

最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板