我決定尋求幫助,我就是無法理解 NGRX 實(shí)體?。ù舜a最初由 NX 創(chuàng)建)。我遵循了 NGRX Entity 指南,我也看了很多教程視頻,但我仍然無法讓NGRX Entity updateOne工作。在下面收到此錯(cuò)誤 - 我可以毫無問題地將實(shí)體加載到商店中,并且這些可以很好地構(gòu)建我的 UI。我有一個(gè)實(shí)體按鈕集合,并希望在單擊時(shí)更新按鈕的存儲(chǔ)狀態(tài) - 僅此而已?。ㄈ魏蜗敕槭裁催@不起作用??)ERROR TypeError: Cannot read property 'id' of undefined at http://localhost:4200/vendor.js:83815:26 at Array.filter (<anonymous>) at updateManyMutably (http://localhost:4200/vendor.js:83811:27) at updateOneMutably (http://localhost:4200/vendor.js:83801:16) at Object.operation [as updateOne] (http://localhost:4200/vendor.js:83622:27) at http://localhost:4200/main.js:1169:28 at http://localhost:4200/vendor.js:88532:26 at reducer (http://localhost:4200/main.js:1173:12) at http://localhost:4200/vendor.js:87072:20 at combination (http://localhost:4200/vendor.js:86960:37) 這是我到目前為止的代碼:// stateexport interface QuickButton { id: number; isSelected: boolean; title: string; linkUrl: string;}// in componentthis.store.dispatch( actions.setQuickFilter( evt ) );// evt = {id: 1, isSelected: true, linkUrl: "", title: "Video"}// in actionsexport const setQuickFilter = createAction( '[QuickBar] setQuickFilter', props<{update: Update<QuickButton>}>());// in reducerexport const QUICKBAR_FEATURE_KEY = 'quickBar';export interface State extends EntityState<QuickButton> { selectedId?: string | number; // which QuickBar record selected loaded: boolean; // has the QuickBar list been loaded error?: string | null; // last none error (if any)}export interface QuickBarPartialState { readonly [QUICKBAR_FEATURE_KEY]: State;}export const quickBarAdapter: EntityAdapter<QuickButton> = createEntityAdapter<QuickButton>();export const initialState = quickBarAdapter.getInitialState({ // set initial required properties loaded: false,});const quickBarReducer = createReducer( initialState,
NGRX 實(shí)體 updateOne 不工作:id undefined
素胚勾勒不出你
2023-03-10 13:59:26