问题描述
我正在尝试通过 CDN 将 Cropperjs 添加到我正在做的项目中。我遇到的问题是,当我尝试实例化 Cropper 对象的新实例时,VSCode 不会将其着色为类;它就像一个函数一样给它上色。
未捕获的引用错误:Cropper 是 未在 FileReader.reader.onload (common.js:180) 处定义
$("#filePhoto").change(function(){ //Todo Check with arrow function?
if(this.files&& this.files[0]){ //check there's one item in the array
var reader = new FileReader();
reader.onload = (e)=>{
var image = document.getElementById('imagePreview');
image.scr= e.target.result;
if(cropper !== undefined){
cropper.destroy();
}
cropper = new Cropper(image,{
aspectRatio: 1 / 1,background: false
});
}
reader.readAsDataURL(this.files[0]);
}
})
我不明白为什么它不起作用。当我在浏览器 DevTools 中检查 Sources 时,Cropper 的 JS 和 CSS 文件已正确加载。
提前感谢您对此的任何见解...
PS:在 https://pastebin.com/aMge1GTb 中添加了测试代码
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)