반응형
Vuex 모듈에서 관찰자 유형 대신 개체 값 가져오기
변환 내부의 Vuex 모듈 상태 값을 얻으려고 합니다.하지만 저는 항상 실제 객체 대신 옵저버 객체를 얻습니다.
@Module({
namespaced: true,
name: 'myModule',
dynamic: true,
store
})
export class MyModule extends VuexModule {
public users: ArrayToObjMap<Users> = {};
@Action
public async initialize() {
const fetchedUsers = await UsersService.getUsers();
this.context.commit('setUsers', fetchedUsers);
}
@Mutation
public setUsers(usersList: string[]) {
this.users = GlobalUtils.mapIdsToItems(usersList, this.users)[0];
}
}
Inside setUsers Mutation, 값this.users
항상 옵저버입니다.반복할 수 있는 단순한 대상을 찾아야 해요.저는 이미 몇 가지 해결책을 시도했습니다.
JSON.parse(JSON.strinfigy(this.users));
=> 빈 개체를 반환합니다.cloneDeep(this.users);
=> 빈 개체를 반환합니다.
언급URL : https://stackoverflow.com/questions/69820342/get-object-value-instead-of-observer-type-in-vuex-module
반응형
'programing' 카테고리의 다른 글
Mixins Vuejs에서 기능을 찾을 수 없습니다. (0) | 2022.08.13 |
---|---|
Vue 어플리케이션에서 Vuex를 사용하여 대용량 데이터셋을 효율적으로 처리 (0) | 2022.08.13 |
오류: "[X][mM][lL]"과(와) 일치하는 처리 명령 대상은 허용되지 않습니다. (0) | 2022.08.13 |
C의 catch 문을 시험합니다. (0) | 2022.08.13 |
Vue.js 3 - Vue 컴포넌트 간에 데이터를 전달하고 두 뷰 모두 업데이트하려면 어떻게 해야 합니까? (0) | 2022.08.13 |