daily pastebin goal
9%
SHARE
TWEET

Untitled

a guest Oct 19th, 2018 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Vue.use(Vuex)
  2.  
  3. export default new Vuex.Store({
  4.   modules: {
  5.     moduleOne, moduleTwo
  6.   }
  7. })
  8.    
  9. state: {
  10. loading: 'null'
  11. },
  12. mutations: {
  13.     setError (state, payload) {
  14.       state.loading = payload
  15.     }
  16.   },
  17. getters: {
  18.     getError(state) {
  19.        return state.loadings
  20.     }
  21. },
  22. action: {
  23.     changeError({commit}, payload) {
  24.       commit('setLoading', payload)
  25.     }
  26. }
  27.    
  28. state: {
  29.   someObject: ''
  30.   },
  31.  
  32. mutations: {
  33.    setSomeObject(state, payload) { state.someObject = payload }
  34. },
  35.  
  36. getters: {
  37.    getSomeObject(state) { return state.someObject }
  38. },
  39.  
  40. action: {
  41.    fetchSomeObject({commit}, payload) {
  42.    commit('setLoading', null)
  43.    /** какие-то асинхронные операции */
  44.    then(response => {
  45.    commit('setSomeobject', response.data)
  46. })
  47. .catch(e=> {commit('SetError', e.message)}
  48. )
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top