<el-upload
action="#"
class="upload-file"
ref="uploadRef"
:on-preview="handlePreview"
:on-remove="handleRemove"
:on-change="handleChange"
:file-list="fileList"
:auto-upload="false">
<el-button type="primary" icon="el-icon-my-cloud" plain @click="">上传文件</el-button>
</el-upload>
//在新窗口打开文件
handlePreview(file) {
console.log('预览文件', file);
if (file.raw.type === "application/pdf") {
const blob = new Blob([file.raw], {type: 'application/pdf'})
window.open(URL.createObjectURL(blob), "_block");
} else if (file.raw.type.includes('image')) {
const blob = new Blob([file.raw], {type: file.raw.type})
window.open(URL.createObjectURL(blob), "_block");
}
},