组件懒加载项目应用
需求:减少项目打包体积
1、懒加载组件引用方式
const MakeProgress = () => import("@/components/makeProgress")
2、懒加载后组件多次打开create钩子无效,需要在mounted中加载初始化方法
3、如果页面使用keep-alive缓存,需要在mounted中使用
this.$nextTick(() => {
this.initData(this.information)
})
此时 方法才能生效
注:被keep-alive缓存的页面,其方法需要在activated() 钩子中才会被再次调用