data() {
return: {
user: {},
userName: "",
userAge: ""
}
},
methods: {
saveUserName: function() {
this.userName = this.newUserName;
this.$refs.userNameModal.hideModal();
this.$session.set('userDetails', {userName: this.userName});
},
saveUserAge: function() {
this.userAge = this.newUserAge;
this.$refs.userAgeModal.hideModal();
this.$session.set('userDetails', {userAge: this.userAge});
},
},
beforeMount: function() {
if (this.$session.exists('userDetails')) {
this.user = this.$session.get('userDetails');
console.log("userDetails", this.user)
}
}
I have a specific form setup for users where each entry requires filling in a modal that pops up. Upon pressing the "done" button, a corresponding function is called to save the entered information and store it in session storage. However, I'm facing an issue where only one value can be stored at a time, causing the previous entry to get reset by the new one. Is there a way to properly populate the 'user' object with both username and user age values simultaneously in the session storage instead of having them overwrite each other? I expect the 'beforeMount' log to display something like: user: {userName: "Mario", userAge:27} when the session storage is not empty. Thanks!