-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
localStorage를 사용하는데 [object][object], [object][object], [object][object] 이런식으로 데이터가 들어와서 당황했다.
해결 방법은 객체를 저장하기 전에 문자화 하고, 사용할 때 구문을 분석하는 것이다.
/ /Groupstore 로컬스토리지에 내 그룹 저장
localStorage.setItem('myGroups', JSON.stringify(this.myGroups)); //키, 값
// HeaderMainContainer header에서 로컬스토리지에 저장된 데이터 사용
const { group } = this.props.Store;
var myGroup_object = localStorage.getItem('myGroups')
group.myGroups_array(JSON.parse(myGroup_object));
데이터가 잘 저장 된다.
0: {id: 1, imgUrl: null, title: "기술 ", description: "기술페이지입니다.", category: "technology", master: "master",…}
1: {id: 2, imgUrl: null, title: "여행", description: "여행카테고리", category: "travel", master: "master",…}
2: {id: 3, imgUrl: null, title: "비즈니스", description: "비즈니스 페이지입니다.", category: "business",…}
3: {id: 7, imgUrl: null, title: "스포츠", description: "스포츠입니다.", category: "sports", master: "master",…}
참고 사이트
https://stackoverflow.com/questions/2010892/storing-objects-in-html5-localstorage
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels