vue实现大文件切片上传、断点续传、并发数控制等
一、上传按钮和进度条等
<div>
<h2>上传文件</h2>
<div ref="drag" class="drag">
<input class="file" type="file" @change="handlerChange" />
</div>
<el-progress style="width: 500px;" :percentage="progress"></el-progress>
<div style="margin-top: 16px;">
<el-button type="primary" @click="upload">上传</el-button>
</div>
<div>
<p>hash进度条</p>
<el-progress style="width: 500px;" :percentage="hashProgress"></el-progress>
</div>
<div>
<p>网格进度条</p>
<ul class="grid" :style="{'width': gridWidth + 'px'}">
<li class="grid-block" v-for="chunk in chunks" :key="chunk.name">
<div
:class="{ 'uploading': chunk.progress > 0 && chunk.progress < 100, 'success': chunk.progress == 100, 'error': chunk.progress < 0}"
:style="{height: chunk.progress + '%'}"
>
<i class="el-icon-loading" style="color: #f56c6c" v-if="chunk.progress < 100 && chunk.progress > 0"></i>
</div>