1

I'm relatively new to Vuejs & am trying to get this form working but it keeps showing me these errors when i submit. Can anyone guide me on this?

<template>
  <form @submit.prevent="handleSubmit">
    <input class="input" type="text" v-model="user.name">
    <input class="input" type="text" v-model="user.email">
    <input class="input" type="text" v-model="user.phone">
    <button class="button is-primary" type="submit">Submit</button>
  </form>
</template>

<script>
export default {
  data() {
    return {
      user: {
        name: '',
        email: '',
        phone: ''
      },
      test: "BEFORE SUBMIT"
    };
  },
  method: {
    handleSubmit() {
      let user = new user({
        name: this.user.name,
        email: this.user.email,
        phone: this.user.phone,
      });

      this.test = "AFTER SUBMIT";
    }
  }
};
</script>

enter image description here

0

1 Answer 1

2

You're calling handleSubmit method but you haven't defined it on the Vue instance.

That's because you should call the Vue instance property methods, not method, even when you have only 1 method.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.