1.異步組件
const AsyncComponent = () => ({
// 需要加載的組件 (應該是一個 `Promise` 物件)
component: import('./MyComponent.vue'),
// 異步組件加載時使用的組件
loading: LoadingComponent,
// 加載失敗時使用的組件
error: ErrorComponent,
// 展示加載時組件的延時時間,默認值是 200 (毫秒)
delay: 200,
// 如果提供了超時時間且組件加載也超時了,
// 則使用加載失敗時使用的組件,默認值是:`Infinity`
timeout: 3000
})

這里有注意!vue報錯: Parsing error: Unexpected token importeslint 需要安裝 npm install --save-dev @babel/plugin-syntax-dynamic-import 要根據是否是dev或者是serve來安裝
2.slot插槽的使用,組件內使用;把值插入到組件里面進行使用,


3.component標簽的動態使用組件


4.keep-alive如果需要對組件進行快取處理的話(不必瘋狂的切換,可以處理–如果是組件的內容比較大;影響性能)

轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/279820.html
標籤:其他
