在这个文件夹中,导出
export default {
name: "test",
module: {
state: {
permission: JSON.parse(localStorage.getItem('permission')) || null,
cardId: null, //判断业务审核点击待审核信息的id
},
getters: {
},
mutations: {
updataPermission(state, val) {
localStorage.setItem('permission', JSON.stringify(val));
state.permission = val;
},
updateCardId(state, val) {
state.cardId = val;
}
},
actions: {
const data = await app.curl(`/api/public/core/roleManager/getUserPriv?UserID=${loginUser[0].userid}`);
let info = [];
Object.keys(data.userRoles).forEach(key => info.push(data.userRoles[key]));
info = info.reduce((a, b) => a.concat(b), [])
context.commit('updataPermission', info);
},
}
}
}
vue页面中,
computed: {
...mapState({
cardId: (state) => state.test.cardId,
}),
},
在methods函数中,
methods: {
close() {
this.$store.commit("test/updateCardId", 1)
}
}