//属性
const state = { serviceTags: [] }
//读属性
const getters = {
getTags: state => {
return JSON.parse(state.serviceTags)
},
}
//同步写属性
const mutations = {
updateTags(state, newVal) {
state.serviceTags = JSON.stringify(newVal)
},
}
//异步写属性
const actions = {
async submitData(context) {
context.commit('updateTags')
},
async doAsync({ commit }) {
commit('updateTags')
},
}
export default {
namespaced: true,
state,
getters,
mutations,
actions,
}
解决Vue中使用vuex时,数据为{__ob__:observer}问题
最新推荐文章于 2023-08-15 14:30:03 发布