I have constants set up that I want to store in the state:
const day = "25/02/2020";
const timeStart = "08:00";
const timeEnd = "00:00";
In my Vuex file, I have the following setup:
export default new Vuex.Store ({
state: {
dateSelected: [], // selected date
},
mutations: {
saveDateSelected (state, [newDateSelected, newTimeStart, newTimeEnd]) {
const newobject = {
DateStart: newDateSelected + "-" + newTimeStart,
DateEnd: newDateSelected + "-" + newTimeEnd,
};
state.dateSelected.push(newobject);
}
},
When I try to access the data in my component with:
this.saveDateSelected(day, timeStart, timeEnd);
If I console.log(this.dateSelected);, the output is:
DateEnd: "2 - /"
DateStart: "2 - 5"
But what I'm expecting is:
DateEnd: "25/02/2020 - 00:00"
DateStart: "25/02/2020 - 08:00"