npm i file-saver
import { saveAs } from "file-saver";
downloadData(url, newFilename){//传入url和名字
var bewName = decodeURIComponent(newFilename).toLowerCase();
saveAs(url, bewName, true);
},
<div class="uploadContent" v-if="fileAccessorysShow.length>0 &&disabled">
<label
for="emergency"
class="el-form-item__label"
style="margin-left:0px;color: #606266; font-size: 18px"
>附件:</label>
<div style="margin-left:64px;line-height:40px">
<dl class="list-files-box">
<dd v-for="(item,index) in fileAccessorysShow" :key="index"
style="width: 200px;float: left;">
<ul>
<li class="list-logo"></li>
<li class="list-name">{{item.name}}</li>
<!-- <li class="list-name">{{'今天是个好日子西'}}</li> -->
<li class="username"></li>
<!-- <li class="file-times">{{setuptime(item.createdDate)}}</li> -->
<li class="downdelfile">
<p class="el-icon-download" @click="downloadData(item.url,item.name)"></p>
</li>
</ul>
</dd>
</dl>
</div>
</div>
.uploadContent {
.list-files-box {
margin-top: 16px;
dd {
// margin-bottom: 16px;
&:last-child {
margin-bottom: 0;
}
}
ul {
display: flex;
align-items: center;
color: rgba(13, 20, 30, 0.7);
line-height: 40px;
height: 40px;
li {
margin-right: 17px;
}
.list-logo {
width: 13px;
height: 16px;
margin-right: 8px;
background-color: #e0e0e0;
// background: url("../../../assets/images/icon_file_pic.png") left top
// no-repeat;
background-size: 100%;
}
.list-name {
line-height: 16px;
font-size: 12px;
}
.downdelfile {
display: flex;
span,
a {
cursor: pointer;
display: block;
margin-right: 7px;
width: 16px;
height: 16px;
color: #aaa;
}
.del {
// background: url("../../../assets/images/filedelbtn.png") left top
// no-repeat;
background-size: 100%;
}
}
}
}
网友评论