Add rows to the table dynamically with the use of vue.js 1

Add rows to the table dynamically with the use of vue.js

url: https://stackoverflow.com/questions/52211682/add-rows-to-the-table-dynamically-with-the-use-of-vue-js

var app = new Vue({
  el: '#app',
  data: {
    mail:'',
    date:'',
    adress:'',
    company:'',
    fliers:'',
    rowData:[] //the declared array
  },
  methods:{
    addItem(){
      var my_object = {
        mail:this.mail,
        date:this.date,
        adress:this.adress,
        company: this.company,
        fliers: this.fliers
      };
      this.rowData.push(my_object)

      this.mail = '';
      this.date = '';
      this.adress = '';
      this.company = '';
      this.fliers = '';
    }
  }
})

Here is what the above code is Doing:
1. We have a form with 5 input fields.
2. We have a button that calls the addItem() method.
3. The addItem() method is pushing the data from the input fields into the rowData array.
4. The rowData array is being used to display the data in the table.

Similar Posts