【问题标题】:Unable to import the List module from immutable.js into Angular 2 project无法将列表模块从 immutable.js 导入 Angular 2 项目
【发布时间】:2017-05-11 14:03:53
【问题描述】:

我正在尝试在新的 Angular 2 项目中使用 immutable.js 中的 List 模块。当我这样做时,浏览器会尝试 GET http://localhost:3000/immutable 并失败并出现 404 Not Found 错误。

这是我所做的:

然后我修改了app.module.ts如下:

import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent }  from './app.component';
import { List } from 'immutable';

@NgModule({
  imports:      [ BrowserModule ],
  declarations: [ AppComponent ],
  bootstrap:    [ AppComponent ]
})
export class AppModule { 
  constructor() {
    let list = List.of(1,2,3);
  }
}

当我npm start 项目时,我收到 404 错误。

我是否遗漏了一些明显的东西?

【问题讨论】:

    标签: javascript angular typescript immutable.js


    【解决方案1】:

    经过更多的谷歌搜索,我发现答案很简单。我只需要在 systemjs.config.js 中向地图添加一个新元素:

    // other libraries
    [...]
    'immutable': 'node_modules/immutable/dist/immutable.js'
    

    【讨论】:

      猜你喜欢
      • 2017-07-11
      • 2021-07-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-28
      • 1970-01-01
      • 1970-01-01
      • 2016-10-29
      相关资源
      最近更新 更多