I need to create an web-app that has only 2 pages. There are two stages of filling out forms on the first page. I can't create two separate pages. Two forms on one page. So how do I stay on the second form when the page is reloaded?
Here is me component Register.vue:
<form v-if="step === 1">
<!-- some input fields about new user -->
</form>
<form v-if="step === 1">
<!-- some input fields about additional info about new user -->
</form>
What I tried:
data() {
return {
step: 1
}
},
mounted() {
if (performance.navigation.type == 1) {
if (this.step === 1) {
this.step = 1;
}
if (this.step === 2) {
this.step = 2;
}
}
},
Also tried to do the same in the created hook.
Any help would be much appreciated.
You can keep step inside the session storage so that the value will not be lost while reloading.
To set the value:
sessionStorage.setItem("step", step)
To retrieve the value:
sessionStorage.getItem("step")