js manually add and delete tableData data

increase data

Add a piece of data to the pop-up window of the subcomponent

    onConfirmed(resolve) {
    
    
      let formData = this.$refs.Form.formParams;
      let arr = [];
      arr[0] = formData;
      console.log("xxx", formData);
      console.log(arr[0], 32333);
      this.listArray.push(arr[0]);
      console.log(this.listArray, 6666);
      this.$emit("toListData", this.listArray);
      resolve();
    },

The parent component accepts data and renders - the child passes parameters to the parent

    getListData(e) {
    
    
      this.listData = e;
      this.$refs.List.tableData = this.listData;
    },

Notice

The component used is based on the encapsulation of element ui.
The tableData property is not set
. $refs is used to set the value of the subcomponent

delete data

 callback: (data) => {
    
    
                  this.listData.splice(data.rowIndex, 1);
                  this.$refs.List.tableData = this.listData;
                },

splice()

Note: For the delete operation of the splice method, the deleted array is the original array, that is, the new array is not returned directly

The first parameter starts from a certain subscript and
the second parameter deletes several elements

Guess you like

Origin blog.csdn.net/Xiang_Gong_Ya_/article/details/131715888