Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { createStore, Store } from 'vuex'
- import { InjectionKey } from 'vue';
- import { Todo } from '@/ts/types';
- // definition of typings for the store state
- export interface State {
- todos: Todo[];
- numbers: number[];
- }
- // define injection key
- export const key: InjectionKey<Store<State>> = Symbol()
- export const store = createStore<State>({
- state: {
- todos: [
- {
- id: 1,
- goal: 'learn vue 3'
- }
- ],
- numbers: [1,2,3,4]
- },
- mutations: {
- },
- actions: {
- },
- modules: {
- },
- getters: {
- getTodos: (state) => {
- return state.todos;
- }
- }
- })
Advertisement
Add Comment
Please, Sign In to add comment