reduce函数导致错误
The reduce function causing errors
chrome 控制台中显示的错误:
1. http://localhost:3000/vendor/@ngrx/store/index.js
Failed to load resource: the server responded with a status of 404 (Not Found)
2. localhost/:19 Error: Error: XHR error (404 Not Found)
loading http://localhost:3000/vendor/@ngrx/store/index.js(…)
(anonymous function) @ localhost/:19
reducer.ts:
*我找不到 something1 return 值的类型和状态类型的合适类型。
import { Action} from '@ngrx/store';
export const something1 = (state: any = {}, action:Action) => {
switch (action.type) {
default:
return state;
}
};
main.ts:删除 "provideStore({something1})" 将导致应用正常运行
import { bootstrap } from '@angular/platform-browser-dynamic';
import { AppComponent } from './app.component';
import { disableDeprecatedForms, provideForms } from '@angular/forms';
import {AccountService} from "./account.service";
import {provideStore} from '@ngrx/store';
import {something1} from "./reducer";
bootstrap(AppComponent, [
AccountService,
disableDeprecatedForms(),
provideForms(),
provideStore({something1})
])
.catch((err: any) => console.error(err));
已解决!
我在 systemjs.config.js 内部映射中将“@ngrx”的值从 vendor/@ngrx 更改为 'node_modules/@ngrx'。
chrome 控制台中显示的错误:
1. http://localhost:3000/vendor/@ngrx/store/index.js
Failed to load resource: the server responded with a status of 404 (Not Found)
2. localhost/:19 Error: Error: XHR error (404 Not Found)
loading http://localhost:3000/vendor/@ngrx/store/index.js(…)
(anonymous function) @ localhost/:19
reducer.ts: *我找不到 something1 return 值的类型和状态类型的合适类型。
import { Action} from '@ngrx/store';
export const something1 = (state: any = {}, action:Action) => {
switch (action.type) {
default:
return state;
}
};
main.ts:删除 "provideStore({something1})" 将导致应用正常运行
import { bootstrap } from '@angular/platform-browser-dynamic';
import { AppComponent } from './app.component';
import { disableDeprecatedForms, provideForms } from '@angular/forms';
import {AccountService} from "./account.service";
import {provideStore} from '@ngrx/store';
import {something1} from "./reducer";
bootstrap(AppComponent, [
AccountService,
disableDeprecatedForms(),
provideForms(),
provideStore({something1})
])
.catch((err: any) => console.error(err));
已解决!
我在 systemjs.config.js 内部映射中将“@ngrx”的值从 vendor/@ngrx 更改为 'node_modules/@ngrx'。