【问题标题】:Angular 2 ParamMapAngular 2 参数映射
【发布时间】:2017-08-16 09:30:23
【问题描述】:

我尝试通过网站 angular.io 上的英雄之旅学习 Angular 2,现在我陷入了路由器方法 >> ParamMap,我添加了一行:

import { ActivatedRoute, ParamMap } from '@angular/router';

但编译器显示错误“模块'路径...'没有导出的成员'ParamMap'”

我通过 Angular CLI 构建了我的项目。

文件 package.json

@angular/router": "^3.3.1"

我在文件夹 @angular/router/src/index.d.ts export ParamMap 中搜索但我没有找到,进入 API 但网站显示路径:router/src/shared.ts 但我也没有找到这堂课。 我建议在新版本中删除这个类,反之亦然在新的 Angular 4 中添加。 如何解决此错误?

【问题讨论】:

    标签: angular2-routing


    【解决方案1】:

    对于遇到此问题的其他人,这里是如何将您的 Angular 版本从 2 或 3 升级到 npm 中的最新版本。

    在 Unix 上

    npm install @angular/{common,compiler,compiler-cli,core,forms,http,platform-browser,platform-browser-dynamic,platform-server,router,animations}@latest typescript@latest --save
    

    在 Windows 上

    npm install @angular/common@latest @angular/compiler@latest @angular/compiler-cli@latest @angular/core@latest @angular/forms@latest @angular/http@latest @angular/platform-browser@latest @angular/platform-browser-dynamic@latest @angular/platform-server@latest @angular/router@latest @angular/animations@latest typescript@latest --save
    

    在这里找到解决方案:https://progblog.io/How-to-upgrade-to-Angular-4/

    【讨论】:

      【解决方案2】:

      我解决了这个问题,我重新安装了 angular-cli,然后在我的项目中删除了 node_modules 文件夹,然后我用新的依赖项(angular4 等)更改了我的 package.json,然后安装了所有依赖项并运行服务器,之后我没有收到错误。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-10-18
        • 2023-03-14
        • 2016-07-09
        • 2023-03-02
        • 2016-08-12
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多