Guest User

Untitled

a guest
Jan 13th, 2021
13
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. import { createStore, Store } from 'vuex'
  2. import { InjectionKey } from 'vue';
  3.  
  4. import { Todo } from '@/ts/types';
  5.  
  6. // definition of typings for the store state
  7. export interface State {
  8. todos: Todo[];
  9. numbers: number[];
  10. }
  11.  
  12. // define injection key
  13. export const key: InjectionKey<Store<State>> = Symbol()
  14.  
  15. export const store = createStore<State>({
  16. state: {
  17. todos: [
  18. {
  19. id: 1,
  20. goal: 'learn vue 3'
  21. }
  22. ],
  23. numbers: [1,2,3,4]
  24. },
  25. mutations: {
  26. },
  27. actions: {
  28. },
  29. modules: {
  30. },
  31. getters: {
  32. getTodos: (state) => {
  33. return state.todos;
  34. }
  35. }
  36. })
  37.  
Advertisement
Add Comment
Please, Sign In to add comment