[Vuejs]-Submit event should be emitted when submitting form

0👍

submit() {
  if(this.username != "" && this.password != "") {
    this.$emit("submit", this.username && this.password)
  } else {
    console.log("Not logged in")
  }
}

In your parent component, you can listen for the submit event emitted by your child component like this:

<LoginForm @submit="handleSubmit" />


methods: {
  handleSubmit(data) {
    console.log(data)
  }
}

Leave a comment