Answer the question
In order to leave comments, you need to log in
How to save current user data when leaving his page in Vue?
Guys and hello again.
There is a page with user data where he can edit them.
There are no buttons. the data needs to be saved before it leaves the page.
tried through
beforeRouteLeave(to, from, nextr) {
debugger
this.$store.dispatch('saveUserData', this.user);
next();
}
export const saveUserData = ({commit}, user) => {
debugger
commit(types.SAVE_USER_DATA), {
user: user
}
}
[types.SAVE_USER_DATA] (state, { user }) {
debugger
state.user = user
}
Answer the question
In order to leave comments, you need to log in
This post is weird:
commit(types.SAVE_USER_DATA), {
user: user
}
commit(types.SAVE_USER_DATA, {user: user})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question