需求:用vue框架,结合element-ui进行本地文件得上传,同时对文件需要MD5
界面如下:
![](https://i-blog.csdnimg.cn/blog_migrate/a0741ce84cae7a2fa9638de6036893fd.png)
同时如果截止时间到了后,需要置灰对应的按钮:发布按钮、导入按钮、删除按钮
html:
就是element-ui得上传组件
auto-upload:true自动上传
beforeUpload:上传之前把对应的文件得信息以及参数拼接好
disabled:截至时间后置灰导入按钮
其他参数没怎么用
<el-upload
class="upload-file"
action="/ignore/"
:before-upload="beforeUpload"
ref="newupload"
multiple
:auto-upload="true"
:disabled="isGrey"
>
<el-button type="text" plain :disabled="isGrey">导入</el-button>
</el-upload>
js:因为要用md5以及一些分块,所以安装了browser-md5-file
import BMF from 'browser-md5-file';//先安装,再引用
const bmf = new BMF();
methods:{
/* 上传文件之前得处理 */
beforeUpload(file){
console.log('当前的文件信息',file)
this.timestamp = new