热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Angular2Module没有导出成员-Angular2Modulehasnoexportedmember

HereIamagain,hopingtofindaquicksolutiontothis:在这里,我再次希望找到一个快速解决方案:Link<-Clickon

Here I am again, hoping to find a quick solution to this:

在这里,我再次希望找到一个快速解决方案:

Link <- Click on this link to see the folder structure

链接<- 单击此链接可查看文件夹结构

//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);

This is my main.ts file where I import the AppComponent from home main, now the home.main looks like this:

这是我的main.ts文件,我从home main导入AppComponent,现在home.main看起来像这样:

import {Component} from 'angular2/core';

    @Component({
    selector:'home',
    templateUrl:'/index/index.ejs'
    })

    export class InputComponent {
      name = 'test';
     }

However, when I run this, I get: error TS2305: Module '"controllers/home/home.main"' has no exported member 'AppComponent'. ( Same goes for home.controller ).

但是,当我运行它时,我得到:错误TS2305:模块'“controllers / home / home.main”'没有导出成员'AppComponent'。 (同样适用于home.controller)。

Thank you, Alex S.

谢谢Alex S.

3 个解决方案

#1


4  

You should have something like that in your home.main module:

你应该在你的home.main模块中有这样的东西:

@Component({
  (...)
})
export class AppComponent {
}

#2


3  

If you see this error in any @angular modules like router, core, then make sure it is because of the version mismatch of the libraries. Generally all your @angular modules should be of the same version except router.

如果您在任何@angular模块(如路由器,核心)中看到此错误,请确保它是由于库的版本不匹配。通常,除路由器外,所有@angular模块都应该是相同的版本。

for Ex:

对于Ex:

    "@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***

the following combination throws following error

以下组合会引发以下错误

has no exported member

没有导出的成员

I changed the router version to

我将路由器版本更改为

"@angular/router": "^3.0.0"

“@ angular / router”:“^ 3.0.0”

The error is resolved.

错误已解决。

So, until everything is stable stick with your working combination.

所以,直到一切都稳定坚持你的工作组合。

#3


0  

I had this issue even when I had correctly exported the class on my other file. Rebooting my machine fixed it.

即使我在其他文件上正确导出了类,我也遇到了这个问题。重新启动我的机器修复它。


推荐阅读
author-avatar
EvilMaknaeKYU
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有