반응형
반복적으로 해당 데이터를 보여줄때 효율적으로 관리하는 방법
State | Vuex
State Single State Tree Vuex uses a single state tree - that is, this single object contains all your application level state and serves as the "single source of truth." This also means usually you will have only one store for each application. A single st
next.vuex.vuejs.org
예제 코드
변경전
computed: {
image() {
return this.$store.state.about.image
},
name() {
return this.$store.state.about.name
},
email() {
return this.$store.state.about.email
},
blog() {
return this.$store.state.about.blog
},
phone() {
return this.$store.state.about.phone
}
*/
},
변경후
import {mapState} from 'vuex'
computed: {
// ... : 전개 연산자 선언
// ...mapState('모듈명', 배열데이터)
...mapState('about', [
'image',
'name',
'email',
'blog',
'phone'
])
},
반응형
'프론트엔드 > Vue.js' 카테고리의 다른 글
SPA (0) | 2022.01.14 |
---|---|
검색 정보 초기화 및 페이지 전환 스크롤 위치 복구 (0) | 2022.01.13 |
404 페이지 만들기 (0) | 2021.11.03 |
로딩 화면 만들기 (0) | 2021.09.27 |
container 너비 사용자 지정 (0) | 2021.09.23 |