Things in the scope in the element table

Mainly these things: the
Insert picture description here
first one: the current row is stored in $index, the index value in the list of the table, the
second one: the data of this column in the column, the
third one: the data of this row in the row
Specific application:

  //添加套餐的菜品
    addTableItem(index) {
    
    
      console.log(this.goodInfoList.dishesFormatTypeList[index].dishesFormatList)
      let obj = {
    
    
                title:'',
                price:'',
                saleNumber:'',
                total:''
              };
       let arr = this.goodInfoList.dishesFormatTypeList[index].dishesFormatList;
       this.$set(arr, arr.length, obj);    //arr是取得这个列表的地址,arr.length取得要添加元素的索引,obj是要添加的位置
 
    },
     // 删除套餐分组的表格数据
    itemDel(scope,index) {
    
    
      this.$delete(this.goodInfoList.dishesFormatTypeList[index].dishesFormatList, scope.$index);
      //删除的话,两个参数,这个列表的地址,要删除元素的索引
    },

Guess you like

Origin blog.csdn.net/weixin_42349568/article/details/114501502