问题描述

vue element ui上传文件传递额外参数,.net core api接收不到。


解决方案:

.net core api类名上多写了 [ApiController]

前端代码:

<el-dialog

      title="文件上传"

      :visible.sync="dialogUpload"

      width="30%"

      :before-close="handleClose">

      <el-upload

          class="upload-demo"

          ref="upload"

          action="http://localhost:9527/api/Upload/UploadFile"

          :on-preview="handlePreview"

          :on-remove="handleRemove"

          :before-remove="beforeRemove"

          :before-upload="beforeupload"

          multiple

          :on-success="handleSuccess"

          :on-change="handleChange"

          :file-list="fileList"

          :auto-upload="false"

          :data="{'index': rowNo, 'fileType': 1}">

          <el-button size="small" type="primary">选择文件</el-button>          

          <div slot="tip" class="el-upload__tip">仅限.jpg、.png、.pdf、.doc、.docx、.xls、.xlsx类型文件</div>

        </el-upload>   

后端代码:

namespace Expenses.Controllers
{
    [Authorize]
    //[ApiController]
    [Route("api/[controller]")]
    public class ProjectController : ControllerBase
    {

Logo

前往低代码交流专区

更多推荐