Oddbean new post about | logout
 
    <template>
        <div>
            <h1>Add User</h1>
            <form @submit.prevent="addUser">
                <input v-model="name" type="text" placeholder="Name"><br><br>
                <input v-model="email" type="email" placeholder="Email"><br><br>
                <button type="submit">Add User</button>
            </form>
        </div>
    </template>

    <script>
        export default {
          data() {
            return {
              name: '',
              email: ''
            }
          },
          methods: {
            addUser() {
                this.$store.commit('addUser', {name: this.name,email:this.email})
                this.$router.push('/users')
            }
          }
        }
    </script>