Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Calculadora

0

58
Vistas
How do I stay on the second form when the page is reloaded? Vue.js

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.

7 months ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

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")
7 months ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar empleo Planes Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2023 PeakU Inc. All Rights Reserved.