使用@ ngrx/store和@ ngrx/core与System.js模块加载器

ref*_*tor 5 ngrx angular

为了在我的示例Angular 2 [2.4.0]应用程序中使用@ ngrx/store [2.2.1]和@ ngrx/core [1.2.0]进行状态管理,我按照以下步骤操作

  1. 已安装@ ngrx/store [2.2.1]和@ ngrx/core
  2. 添加以下导入到根模块

    import { StoreModule } from '@ngrx/store'; 
    
    Run Code Online (Sandbox Code Playgroud)

3在systemjs.config.js文件的packages部分中添加了以下代码

 '@ngrx/core': {
          main: 'bundles/core.umd.js',
          format: 'cjs'
      },
      '@ngrx/store': {
          main: 'bundles/store.umd.js',
          format: 'cjs'
      }     
Run Code Online (Sandbox Code Playgroud)

当我浏览网站时,我在浏览器控制台中遇到错误

无法加载资源:服务器响应状态为404(未找到)" http:// localhost:62818/@ngrx/store/bundles/store.umd.js "

知道需要修改什么来解决这个问题.

ref*_*tor 6

正如@ estus所提到的,这是一个路径问题.使用正确的路径向地图部分添加以下行可以解决问题

'@ngrx/core': 'node_modules/@ngrx/core/bundles/core.umd.js',
'@ngrx/store': 'node_modules/@ngrx/store/bundles/store.umd.js',
Run Code Online (Sandbox Code Playgroud)