基于el-table的批量删除,点击一行,自动选择或取消当行复选框。报错415,增加‘Content-Type‘

最近有个需求是基于el-table的批量删除功能。其中有几个点记录一下
1、点击一行,自动选择或取消当行复选框。
只需要增加 
  @row-click="clickRow" ref="moviesTable"
 clickRow(row) {
      this.$refs.moviesTable.toggleRowSelection(row)
    },
      
2、批量删除代码。总是报错415。写成axios.delete(url,{data:{param:xx}}) 格式。
    增加'Content-Type': 'application/json'


handleDel() {
      let row = this.currentRow
      console.log(row, 'row')
      if (!row) {
        this.$message({
          message: '请选择要删除的一行数据!',
          type: 'error'
        })
        return
      }
      const reqData = row.map((item) => item.Id)
      var par = {
        ids: `${reqData}`
      }
      
      console.log(reqData, 'reqData')
      this.$confirm(`确定删除选中的 ${row.length} 项吗?`, '提示', {}).then(() => {
        this.$api.DeleteSupplement(par).then((res) => {
          if (res.data.success) {
            this.$message({
              message: '删除成功',
              type: 'success',
              duration: 5000
            })

            this.getData()
          } else {
            this.$message({
              message: res.data.msg,
              type: 'error',
              duration: 5000
            })
          }
        })
      })
    },
//删除补录接口 
export const DeleteSupplement = (data) => {
  return axios.delete(`/sa/ValidAttendDateSupplement/DeleteSupplementBacth`, {data:data}
  ,{ headers: { 'Content-Type': 'application/json' } });
};


版权声明:本文为qq_41426442原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。