[Vuejs]-Input field doesnt work after clear button

0👍

There are two ways you can use any one:

Method 1:

clear () {
this.$refs["form"].resetFields();
}

Method 2:

clear () {
  this.form={
  name="",
  email="",
  desc="",
  date=""
  }
}

0👍

you can use the form ref to reset the fields.
You need to do something like this –

<template>
  <div>
    <!-- YOUR HTML CODE -->
    <form ref="form">
      <!-- YOUR FORM HTML -->
    </form>
  </div>
</template>

Script

  methods: {
    add () {
      this.tableData.push({
        date: new Date(this.form.date).toDateString(),
        name: this.form.name,
        email: this.form.email
      })
    },
    clear () {
      this.$refs.form.resetFields();
    }
  }

Leave a comment