首页 文章

无法将列表模块从immutable.js导入Angular 2项目

提问于
浏览
2

我试图在新的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错误 .

我错过了一些明显的东西吗

1 回答

  • 1

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

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

相关问题