const AsyncComponent= () => import('./AsyncComponent')
new VueRouter({
routes: [
{ path: '/test', component: AsyncComponent}
]
})
Vuex 模块代码分割,vuex中有动态注册模块方法,同时也是加上import
const store = new Vuex.Store()
import('./store/test').then(testModule => {
store.registerModule('test', testModule)
})
总结
在一般项目中,我们按照router和components层面分割(或者只使用router分割)就足够了。大型项目可能三者都会用到,但用法都很简单,不是么?
好了,以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,如果有疑问大家可以留言交流,谢谢大家对黑区网络的支持。
