Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

134
Views
Vue submit Form in LocalStorage

Hi i'm starting to use vue and javascript from some day and i need to do an example of form for my "exame". I would like to save locally the data entered by users and use this data and enter them on another page. Do I have to use a database? (user enter "name" and in the next page "welcome (name)"). This is part of my code:

        <label>Nome:</label>
        <input type="text" required v-model="nome">

        <div class="submit">
            <button>Iscriviti!</button>

export default {
data() {
    return {
        nome: '',
    }
},
methods: {
    inviaForm() {
        console.log('form inviato')
    }
}

Sorry for my english, i'm so bad

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Page 1

<template>
    <div>
        <label>Nome:</label>
        <input type="text" required v-model="nome">

        <div class="submit">
            <button @click="inviaForm">Iscriviti!</button>
        </div>
</template>
<script>
    export default {
        data() {
            return {
                nome: '',
            }
        },
        methods: {
            inviaForm() {
                localStorage.setItem('nome',this.nome)
            }
        }
</script>

Page 2

<template>
    <div>
        <div>Name is: {{nome}}</div>
</template>
<script>
    export default {
        data() {
            return {
                nome: '',
            }
        },
        mounted() {
            this.nome = localStorage.getItem('nome');
        }
    }
</script>
about 4 years ago · Juan Pablo Isaza Report

0

this may help -- just the snippet that would store the name. I reckon you're not into reactive / vuex states, so try this (and in your other component use onMount() { this.nome = localStorage.getItem('name') } to retrieve. You'll figure it out.

<form @submit="inviaForm"> 
     <label>Nome:</label>
     <input type="text" required v-model="nome">
     <button>Iscriviti!</button>
</form>

export default {
data() {
    return {
        nome: '',
    }
},
methods: {
    inviaForm() {
        localStorage.setItem('name', this.nome)
    }
}

.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!