Szkielet ciała Vuex
import Vue from 'vuex'
const state = {
//varriables, consts and arrays using by vuex store
todos: {
id: 1,
name: 'test',
completed: false,
dueDate: '2022-02-13',
dueTime: '14:34'
}
}
const actions = {
//triggered methods by mutations
addTodo(state, payload) {
Vue.set(state.todos, payload.id, payload.todo)
}
}
const mutations = {
//triggered methods by app
addTodo({ commit }, todo) {
let payload = {
todo: todo
}
}
}
const getters = {
//returns state
todos: (state) => {
return state.todos
}
}
export defaults {
namespaced: true,
state,
actions,
mutations,
getters
}
Evil Elk