I am looking to update my object while maintaining reactivity. The variable selectedTime
is a Date object, and the function substractMonths
will return a new Date object.
<span
class="calendar__pickable__chevron"
@click="selectedTime = substractMonths(1, selectedTime)"
>
<span>
<font-awesome-icon icon="chevron-left" />
</span>
</span>
However, I am facing an issue where Vue 3 is unable to detect the replacement of the object when this operation is performed.
Is there a way to resolve this? (I have used
const selectedTime = ref(new Date())
to create a reactive object).
https://i.sstatic.net/DBDDh.png
The substract
function does indeed return a new Date
object.
Excerpt from code: https://gist.github.com/SirMishaa/efb0efe74c6355aabbcb853f7650c22f
My goal is simply to run a function that returns a new date, and replace my selectedTime
with the result of that function.