当build打包后,app.js过大的时候,可以考虑用异步组件的方式。

import HomeHeader from "./components/Header";
import HomeSwiper from "./components/Swiper";
import HomeIcons from "./components/Icons";
import HomeRecommend from "./components/Recommend";
import HomeWeekend from "./components/Weekend";

export default {  
    name: "Home", 
    components: {   
        HomeHeader,     
        HomeSwiper,    
        HomeIcons,   
        HomeRecommend,   
        HomeWeekend  
    } 
}

            

  以下是异步组件加载方式:

export default {
  name: 'Home',

  components: { 
    //异步组件加载方式    
    HomeHeader: () => import("./components/Header"),  
    HomeSwiper: () => import("./components/Swiper"),
    HomeIcons: () => import("./components/Icons"),
    HomeRecommend: () => import("./components/Recommend"),   
    HomeWeekend: () => import("./components/Weekend")  
  }
}

  

posted on 2018-10-08 17:33  chenlw101  阅读(190)  评论(0编辑  收藏  举报