如图,这个file里没有url,有时候我们需要预览或者剪裁,这时候没有url就不行


那就我们自己创建一个url吧
onChange(file, fileList) {
let url = URL.createObjectURL(file.raw)
console.log(file, "onchange的输出");
if (this.selectFile.uid !== file.uid) {
if (this.isCrop) {
this.innerVisible = true;
this.cropOptions.img = url;
this.selectFile = file;
debugger;
} else {
this.$refs.upload.submit();
}
}
},
本文介绍了一种在没有原始URL的情况下,为文件创建URL的方法,以便进行预览和剪裁操作。通过使用JavaScript的URL.createObjectURL方法,可以将文件对象转换为一个临时的URL,从而实现在网页中显示和编辑图片的功能。
4749

被折叠的 条评论
为什么被折叠?



