当使用el-upload上传文件时,如果产生跨域问题,我去掉了:with-credentials='true'设置,并且后端有token验证,将token设置在header中,如下所示:
<el-upload
:action="`${localUrl}${action}`"
:before-upload="beforeUpload"
class="upload"
:data="data"
:file-list="fileList"
:headers="myHeaders"
:limit="1"
multiple
name="file"
:on-preview="handlePreview"
:on-success="sucess"
:show-file-list="false"
>
<el-button icon="el-icon-upload" type="text">导入文件</el-button>
</el-upload>