My dilemma involves an object in the Vuex store containing data that I need to utilize within a component. I have successfully accessed the data using a getter in the component. However, I am facing a challenge in preserving the initial value of this object in a variable without it being affected by any subsequent changes to the data in the store. This is essential for me to perform a comparison condition.
The code snippet provided below demonstrates this situation, where the 'getSelectedLocation' object is the one whose original value needs to be retained.
data() {
return {
toggle: this.getSelectedLocation?.local,
}
},
computed: {
...mapGetters({ getUser: 'user/getUser', getSelectedLocation: 'support/getSelectedLocation' }),
},
methods: {
async updateUsersLocation() {
const usersCol = new UsersCollection(this.$fire.firestore)
const id = this.getUser.id
const location = this.getSelectedLocation
return await usersCol.updateUsersLocation({ id, location })
},
},
}