IT이야기

Vuex에서 모든 개체 하위 속성 보기

cyworld 2022. 5. 24. 21:56
반응형

Vuex에서 모든 개체 하위 속성 보기

나는 다음과 같은 Vuex 개체의 개별 속성을 보고 있다.

this.$store.watch( function(state) {return state.views.height}, function() { //do something } )
this.$store.watch( function(state) {return state.views.width}, function() { //do something } )

의 모든 오브젝트 속성을 볼 수 있는가?state.views개별 속성을 지정하지 않고?

브룩스의watch방법에는 같은 것이 필요하다.options부에의 방식에서 나온 주장A가 있다.deep하위 속성에 대한 모든 변경 내용을 볼 수 있는 옵션

store.watch(
  state => state.views,
  views => console.log('change', views.height, views.width),
  { deep: true } // <-- options
)

데모를 하다

참조URL: https://stackoverflow.com/questions/61052012/vuex-watch-all-object-subproperties

반응형