RT,下面是我的vuex
const state = () => ({
user: {}
})
const mutations = {
setUser (state, val) {
state.user = val
console.log(JSON.parse(JSON.stringify(state.user)))
}
}
const actions = {
setUser: ({ commit }, user) => {
commit('setUser', user)
}
}
export default { namespaced: true, state, mutations, actions }
console.log(JSON.parse(JSON.stringify(state.user)))可以成功打出来如下的东西
但使用mapstate在网页上打出的时候是一个空的括号,问一下有什么可以解决的办法吗谢谢
<Content class="content_background">
{{users}}
</Content>
import { mapState } from 'vuex'
export default {
computed: {
...mapState({ users: state => state.usermodal.user.user })
}
}
猜你
state
改成这样就能响应了