We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
here is my code: ` home.vue async asyncData({ store, route }) { store.registerModule('homepc', homepcStoreModule) return store.dispatch("homepc/getHot"); }, mounted(){ this.$refs.changeHot2.addEventListener('click',function(){ _that.getHotLists(); }) } methods:{ getHotLists(){ return this.$store.dispatch("a/getHot"); }, }
store/index.js import Vue from "vue"; import Vuex from "vuex"; import moduleHomePc from "./homepc"
Vue.use(Vuex);
export function CreateStore() { return new Vuex.Store({ modules:{ a:moduleHomePc } }) }
store/homepc.js import Vue from "vue"; import homePc from "./../assets/js/homePc.js"; export default { namespaced: true, state: ()=>({ hotLists:[] }), mutations: { getHotLists(state, payload) { console.log(state,'hot')// !!!but state is empty object like {hotLists:[]} Vue.set(state, 'hotLists', payload); } }, actions: { getHot({ commit }) { return homePc.getHotLists({}).then(res => { if (res.data.code == '0') { commit('getHotLists', res.data.list); } }); }, } `
I debuged the code console.log(state),open the brower debug mode ,the state is not update. anynone can give a tip ,thanks in advance!
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Uh oh!
There was an error while loading. Please reload this page.
here is my code:
`
home.vue
async asyncData({ store, route }) {
store.registerModule('homepc', homepcStoreModule)
return store.dispatch("homepc/getHot");
},
mounted(){
this.$refs.changeHot2.addEventListener('click',function(){
_that.getHotLists();
})
}
methods:{
getHotLists(){
return this.$store.dispatch("a/getHot");
},
}
store/index.js
import Vue from "vue";
import Vuex from "vuex";
import moduleHomePc from "./homepc"
Vue.use(Vuex);
export function CreateStore() {
return new Vuex.Store({
modules:{
a:moduleHomePc
}
})
}
store/homepc.js
import Vue from "vue";
import homePc from "./../assets/js/homePc.js";
export default {
namespaced: true,
state: ()=>({
hotLists:[]
}),
mutations: {
getHotLists(state, payload) {
console.log(state,'hot')// !!!but state is empty object like {hotLists:[]}
Vue.set(state, 'hotLists', payload);
}
},
actions: {
getHot({ commit }) {
return homePc.getHotLists({}).then(res => {
if (res.data.code == '0') {
commit('getHotLists', res.data.list);
}
});
},
}
`
I debuged the code console.log(state),open the brower debug mode ,the state is not update.
anynone can give a tip ,thanks in advance!
The text was updated successfully, but these errors were encountered: