sourcecode

Vuex에서 알 수 없는 돌연변이 유형 us

copyscript 2022. 8. 16. 23:34
반응형

Vuex에서 알 수 없는 돌연변이 유형 us

요소

computed: {
   score () {
    this.$store.commit('geolocation');
    console.log(this.$store.getters.lat);
   }
}

store.displaces를 설정합니다.

export default {
  state: {
   lat:'ok',
  },
  getters:{
    cordinate(state){
    return state.lat
    }
  },  
  mutations: {
    geolocation(state){
     state.lat
    }
  },
  actions: {
  }
}

App.js

import StoreData from'./store.js';
Vue.use(Vuex);
const store = new Vuex.Store({StoreData});
new Vue({
  el: '#app',
  data: {},
  router: router,
   store,
})

vuex의 신기능.vuex 에서 값을 가져오려고 했지만 다음 오류가 계속 발생했습니다. [vuex] 알 수 없는 변환 유형.내가 뭘 빼놓았나요?

다음과 같이 상태 속성에 값을 할당해야 합니다.

computed: {
   score () {
    this.$store.commit('geolocation',78);
    console.log(this.$store.getters.lat);
   }
}
  mutations: {
    geolocation(state,newLat){
     state.lat=newLat;
    }
  }

Vuex 스토어를 사용하는 경우mutations그리고.actions내부 메서드와 내부 게터 계산 속성입니다.

문제의 원인

고객님의 고객명main.js그랬어야 했는데const store = new Vuex.Store(StoreData);제거하지 않고{}주위에StoreData

언급URL : https://stackoverflow.com/questions/54595332/unknow-mutation-type-usin-vuex

반응형