当前位置:网站首页>uView上传组件upload上传auto-upload模式图片压缩
uView上传组件upload上传auto-upload模式图片压缩
2022-07-28 05:22:00 【Alex_z0897】
参照手动上传的代码改的
https://blog.csdn.net/weixin_43841757/article/details/111040124
上传前的钩子before-upload
html
<u-upload :auto-upload="true"
:before-upload="onBeforeUpload" ref="uUpload1" @on-choose-complete="onChooseComplete(1)"
....略其它
</u-upload>
js
onBeforeUpload(index1, list){
this.isuploading = "正在上传中....";
let self = this
console.log("onBeforeUpload before==========>>>",list[index1].file.size/1024/1024)
// #ifdef H5
return this.$compressImg(list[index1].file )//调用compress
.then(res =>{
let lists =null
if(self.act == 1){
lists = self.$refs.uUpload1.lists
}
if(self.act == 2){
lists = self.$refs.uUpload2.lists
}
if( lists ){
lists.forEach((item, index) => {
if (item.file.name == res.name) {
console.log("compress upload==========>>>",res,res.size/1024/1024)
lists[index].file = res;
lists[index].url = res.path;
}
})
}
})
// #endif
}
边栏推荐
猜你喜欢
随机推荐
Manually create a simple RPC (< - < -)
服务可靠性保障-watchdog
Cookie、Session和Token的区别与联系
Wechat official account - authorized login
4个角度教你选小程序开发工具?
【5】 Redis master-slave synchronization and redis sentinel (sentinel)
MySQL view, stored procedure and stored function
XShell突然间无法连接虚拟机
XML parsing entity tool class
Continuous login problem
【3】 Redis features and functions
撞脸ins? Mars数字藏品平台探索数字藏品轻社交
MySQL trigger
svn incoming内容无法更新下来,且提交报错:svn: E155015: Aborting commit: XXX remains in conflict
预告来袭:【豆冰冰】发.售,现.金.抽.奖等你来拿
Data warehouse tool superset installation (fully available)
mysql5.6(根据.ibd,.frm文件)恢复单表数据
Structured streaming in spark
CertPathValidatorException:validity check failed
Books - Sun Tzu's art of war







