代码语言:javascript复制
const getImgSize = str => {
var strLength = str.url.length;
var fileLength = parseInt(strLength - (strLength / 8) * 2);
var size = '';
size = (fileLength / 1024).toFixed(2);
return parseInt(size);
};
代码语言:javascript复制使用
let imgUrl = getImgSize(files[filesIndex]);
if (imgUrl > 5120) {
return;
}