1.注冊全局組件
2.倒入 路由
子路由較多時。 可以將提取出來
代碼為
export default {
Path:’/’,
name:“/”,
conponent:import…...
child:[
path:’home’,
name:“/”,
conponent:import…...
]
}
也可以作為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 對象中。