const state = () => ({ count: 0, }); const getters = { doubleCount: (state) => state.count * 2, }; const mutations = { add: (state, num = 1) => (state.count += num), }; const actions = { clear: ({ state, commit }) => { commit('add', state.count * -1); }, }; export default { state, getters, mutations, actions, };