vue+element 实现批量新增多行

实现如下批量新增vue+element 实现批量新增多行_第1张图片

  1. 样式
 
  1. 参数声明
 form: {
   list:[{id:'',name:''}]
   }
  1. js方法
    // 新增一行
   addRow(){
      if(this.form.list){
         var index = this.form.list.length - 1;
         var lastItem = JSON.parse(JSON.stringify(this.form.list[index]))
         lastItem.id = ''
         lastItem.name = ''
         this.form,list.push(lastItem)
        }
   }
 

// 删除一行

  delRow(item, index){
      this.form.list.splice(index, 1)
   }

你可能感兴趣的:(elementui,vue)