从索引.ts 导出和导入



我一直在研究角度项目,遇到了这个非常特殊的问题。我已经为布局,登录和仪表板创建了单独的模块。登录时,我想要一个非常具体的布局,所以我这样做了

import { LoginLayout } from '../layouts/login-layout/login-layout.component'; // this works
import { LoginLayout } from '../layouts'; // this doesn't work
import { 
loginRoute,
resetPasswordRoute
} './'; 
const LOGIN_ROUTES = [loginRoute, resetPasswordRoute];
export const loginRoute: Routes = [
path: '',
component: LoginLayoutComponent,
children:  LOGIN_ROUTES
]

我正在将登录布局从layoutsindex.ts导出为

...
export * from './login/login-layout/login-layout.compenent';

我无法理解为什么一个有效而另一个无效 它甚至没有显示任何错误

当比较导入的文件夹结构与index.ts文件中的导出时,有一个额外的文件夹./login/。也许这是您导出的具有不同名称的附加组件。

import { LoginLayout } from '../layouts/login-layout/login-layout.component'; // this works

索引.ts

export * from './login/login-layout/login-layout.compenent';

编辑

这就是我假设的文件夹结构。

├──dashboard
├──layouts
│     ├──index.ts
│     └──login
│            └──login-layout
│                    login-layout.component.ts 
└──login
└──somefile-with-import.ts

最新更新