排序数据

   onChange=(e)=>{
        const { headerList } = this.props;
        const showData = [];
      e.forEach(key => {
        headerList.forEach(item=>{
            if(key===item.dataIndex){
                showData.push(item)
            }
        })
      });
      console.log(showData)
      this.props.columnsChange(showData);
    }
//这样操作 会让形成的数组数据从后往前排。比如说任务id 会排到最后

   onChange=(e)=>{
      const { headerList } = this.props;
      const showData = [];
      headerList.forEach(item=>{
        if(e.includes(item.dataIndex)) {
            showData.push(item)
        }
      })
      console.log(showData)
      this.props.columnsChange(showData);
    }
ES6的includes方法返回的数组会按照原来数组的排序方式进行排序。
原文地址:https://www.cnblogs.com/l8l8/p/9761415.html