1.注册全局组件
![](https://img.haomeiwen.com/i18796961/585e67955289ac9a.png)
2.倒入 路由
子路由较多时。 可以将提取出来
代码为
export default {
Path:’/’,
name:“/”,
conponent:import…...
child:[
path:’home’,
name:“/”,
conponent:import…...
]
}
![](https://img.haomeiwen.com/i18796961/79fe4b7bcb3021e4.png)
![](https://img.haomeiwen.com/i18796961/fc6dad73555ab638.png)
也可以作为store.module的导入
importAll(require.context('../components/', true, /\.js$/));var cache = {};functionimportAll(r){
r.keys().forEach(key => cache[key] = r(key));
}
importAll(require.context('../components/', true, /\.js$/));// 在构建时(build-time),所有被 require 的模块都会被填充到 cache 对象中。
网友评论