【发布时间】:2017-08-13 01:03:12
【问题描述】:
我在 ES6 中使用 babel 导入多个模块时遇到问题。我正在尝试在 Vue.js 中将我的应用程序构建为模块化组件(或者准确地说是 Angular2 中遵循的功能结构)
app/
moduleA/
components/
vuex/
index.js
routes.js
moduleB/
components/
vuex/
index.js
routes.js
index.js
routers.js
vuex.js
components.js
router/
vuex/
components/ -> shared
main.js
现在,我的问题是,如何导出和导入所有模块才能完美运行?
假设对于 moduleA 路由,我有以下代码
//moduleA/routes.js
export const routes = [
{ path: '', name: 'home', components: {
default: Home,
'header-top': Header
} }
];
对于 moduleB 路由再次
//moduleA/routes.js
export const routes = [
{ path: '/user', components: {
default: User,
'header-bottom': Header
}, children: [
{ path: '', component: UserStart },
{ path: ':id', component: UserDetail },
{ path: ':id/edit', component: UserEdit, name: 'userEdit' }
] }
];
那么,我该如何导入并获得这项工作。请帮忙。
谢谢
【问题讨论】:
-
有什么难度?两者都在导出名为
routes的东西?
标签: javascript vue.js babeljs vuejs2 vue-component