Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. // store.js
  2.  
  3. import Vue from "vue";
  4. import Vuex from "vuex";
  5.  
  6. Vue.use(Vuex);
  7.  
  8. export const store = new Vuex.Store({
  9. state: {
  10. foods: []
  11. },
  12.  
  13. mutations: {
  14. addFood(state, { payload }) {
  15. state.foods.push(payload);
  16. },
  17. },
  18.  
  19. actions: {
  20. addFood({ commit }, payload) {
  21. commit("addFood", { payload });
  22. },
  23. },
  24.  
  25. getters: {
  26. foods: state => state.foods
  27. }
  28. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement