Angular 2 Module没有导出成员
在这里,我再次希望find一个快速的解决scheme:
链接< – 点击此链接查看文件夹结构
//main.ts import {bootstrap} from 'angular2/platform/browser'; import {AppComponent} from './home.main'; import {InputComponent} from './home.controller'; import {enableProdMode} from 'angular2/core'; bootstrap(InputComponent); bootstrap(AppComponent);
这是我的main.ts文件,我从家庭主要导入AppComponent,现在home.main看起来像这样:
import {Component} from 'angular2/core'; @Component({ selector:'home', templateUrl:'/index/index.ejs' }) export class InputComponent { name = 'test'; }
但是,当我运行这个时,我得到: error TS2305: Module '"controllers/home/home.main"' has no exported member 'AppComponent'. ( Same goes for home.controller ).
error TS2305: Module '"controllers/home/home.main"' has no exported member 'AppComponent'. ( Same goes for home.controller ).
谢谢Alex S.
你应该在home.main模块中有这样的东西:
@Component({ (...) }) export class AppComponent { }
如果你在路由器 , 核心等任何@angular模块中看到这个错误,那么确定它是由于库的版本不匹配造成的。 一般来说,除了路由器,你所有的@angular模块都应该是相同的版本。
例如:
"@angular/common": "2.2.3", "@angular/compiler": "2.2.3", "@angular/core": "2.2.3", "@angular/platform-browser": "2.2.3", "@angular/platform-browser-dynamic": "2.2.3", "@angular/router": "^3.3.0" <= Version mismatch***
下面的组合会抛出以下错误
没有出口成员
我改变了路由器版本
“@ angular / router”:“^ 3.0.0”
错误已解决。
所以,直到一切稳定坚持你的工作组合。
即使在我的其他文件上正确导出该类时,我也遇到了这个问题。 重新启动我的机器固定它。
- (TypeScript)为Parse SDK(浏览器和节点)创buildtypes定义
- 在VSCode中为节点模块使用自己的打字稿types定义
- create-react-app-typescript:error TS2304:找不到名字'require'
- 如何扩展Error类?
- Jest,Typescript,ts-jest:覆盖率稍微不正确
- 即使在使用箭头function的情况下,“这”在打字稿中也是未定义的
- 我怎样才能得到TypeScript加载PDF.js NPM模块和@types绑定生成工作Node.JS代码的方式?
- Node的WebStorm代码完成显示了太多的选项
- 获取错误:如何从打字稿中正确使用我的转录和打字的打字稿npm模块?