
원래 이렇게 썻다 ↓
computed : {
name(){
return this.$store.state.name
}
}
그러나 수가 많으면 너무 코드가 길어지므로
computed : {
name(){
return this.$store.state.name
},
age(){
return this.$store.state.name
},
gender(){
return this.$store.state.name
}
}
이렇게된다
너무 길어지니까 아래와같이
import {mapState} from 'vuex'
computed : {
...mapState(['name', 'age'])
...mapMutations([ 'gender', 'state' ])
...mapActions([ 'country', 'comment' ])
}
간략해진다
아무튼 컴퓨티드를 활용하면
$store.state.setMore //이렇게 쓸 필요 없이
{{setMore}} //이렇게 쓰면됨