<template>
<el-upload
class="upload-demo"
action=" " //必选参数,上传的地址
:multiple="true" //是否支持多选文件
:limit="5" //最大允许上传个数
accept="image/png, image/jpeg" //接受上传的文件类型
:on-change="(file,fileList) => {uploadChange(file,fileList,'reexaminationForm')}" //文件状态改变时的钩子
:on-remove="(file,fileList) => {handleRemove(file,fileList,'reexaminationForm')}"
//文件列表移除文件时的钩子
:before-remove="beforeRemove" //删除文件之前的钩子
:on-exceed="handleExceed" //文件超出个数限制时的钩子
:auto-upload="false" //是否在选取文件后立即进行上传
:file-list="reexaminationForm.fileList"> //上传的文件列表
<el-button size="mini" type="primary">点击上传</el-button>
</el-upload>
</template>
<script>
const vm = new Vue({
el: "#app",
data() {
return {
//表单存在多个,这里仅列出一个
reexaminationForm: {
fileList: []
},
imgList: []
}
},
methods: {
uploadChange(file, fileList, formName) {
vm[formName].fileList.push(file); //保存文件到相应表单下的fileList
vm.transformBase64(vm[formNa