In my quest to modify a moment.js
instance housed in a vue.js
computed property, I have encountered a challenge.
computed: {
currentDate() {
return moment();
}
}
Attempting to update it with a method like this one has proved ineffective:
methods: {
prevMonth() {
this.currentDate = moment(this.currentDate).subtract(1, 'months');
}
}
This issue seems to be rooted in the fact that computed properties only function as getters (and potentially setters). How can I alter this behavior?
I simplified the example, as I utilize the computed property for data retrieval from my vuex
store. Unfortunately, manipulating it is now proving challenging.
Is there a way to populate a local currentDate
property with the value from the vuex
store so I can continue modifying it by adding months and more?
I considered using the mounted
property for this purpose, but since I only mount my component once, it may not be suitable. Any guidance on this issue would be greatly appreciated.