<el-badge
:value="$store.state.app.notice"
:max="99"
class="item"
:hidden="$store.state.app.notice>0?false:true"
>
</el-badge>
this.$store.commit("app/SET_APPRAISE", res.data.appraise); //同步
store.dispatch("app/toggleNavbar", i); //异步
//store/app.js
const state = {
notice: undefined,
}
const mutations = {
SET_NOTICE: (state, val) => {
state.notice = val
},
}
store/index.js
Vue.use(Vuex)
const store = new Vuex.Store({
modules: {
app,
permission,
settings,
user,
},
getters
})