Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Vue.use(Vuex)
- export default new Vuex.Store({
- modules: {
- moduleOne, moduleTwo
- }
- })
- state: {
- loading: 'null'
- },
- mutations: {
- setError (state, payload) {
- state.loading = payload
- }
- },
- getters: {
- getError(state) {
- return state.loadings
- }
- },
- action: {
- changeError({commit}, payload) {
- commit('setLoading', payload)
- }
- }
- state: {
- someObject: ''
- },
- mutations: {
- setSomeObject(state, payload) { state.someObject = payload }
- },
- getters: {
- getSomeObject(state) { return state.someObject }
- },
- action: {
- fetchSomeObject({commit}, payload) {
- commit('setLoading', null)
- /** какие-то асинхронные операции */
- then(response => {
- commit('setSomeobject', response.data)
- })
- .catch(e=> {commit('SetError', e.message)}
- )
Add Comment
Please, Sign In to add comment