vue-router實現路由懶加載?

vue-router實現路由懶加載?
其實很簡單,就是將你在index.js中的import路徑文件換一個方式來寫
通常來說咱們剛剛寫index.js中的路徑的時候都會書寫import 組件名字 from ‘。。。路徑。。。’vue

但當咱們須要懶加載的時候
咱們要把這個import的方式從新改寫一下,有兩種方法vue-router

第一種
const 組件名字 =()=> import ( ‘組件地址’)

第二種
const 組件名字 =(resolve) =>{
    import(’組件地址’).then((module=>{
        resolve(module)
    })
}

就完成啦code

相關文章
相關標籤/搜索