将@ngrx/存储和@ngrx/核心与系统.js模块加载器一起使用



为了在我的示例 Angular 2 [2.4.0] 应用程序中使用 @ngrx/store [ 2.2.1 ] 和 @ngrx/core [ 1.2.0 ] 进行状态管理

  1. 已安装@ngrx/存储 [ 2.2.1 ] 和@ngrx/核心
  2. 下面添加了导入到根模块

    import { StoreModule } from '@ngrx/store'; 
    

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

 '@ngrx/core': {
          main: 'bundles/core.umd.js',
          format: 'cjs'
      },
      '@ngrx/store': {
          main: 'bundles/store.umd.js',
          format: 'cjs'
      }     

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

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

知道需要修改什么才能解决此问题。

正如@estus提到的,这是一个路径问题。将以下行添加到具有正确路径的地图部分解决了问题

'@ngrx/core': 'node_modules/@ngrx/core/bundles/core.umd.js',
'@ngrx/store': 'node_modules/@ngrx/store/bundles/store.umd.js',

最新更新