Open yjp1105286534 opened 4 years ago
当我打包到生产环境运行时 浏览器提示我原因XMLHttpRequest在同步请求下 responseType不允许被设置,报错 解决办法 dist/croppper.js 注释掉 // xhr.responseType = 'arraybuffer'; xhr.withCredentials = element.crossOrigin === 'use-credentials'; xhr.send(); 然后再这个方法里加上 stringToArrayBuffer方法 xhr.onload = function () { _this.read(stringToArrayBuffer(xhr.response)); };
function stringToArrayBuffer(str) { var buf = new ArrayBuffer(str.length); var bufView = new Uint8Array(buf);
for (var i=0, strLen=str.length; i<strLen; i++) { bufView[i] = str.charCodeAt(i); } return buf;
}
当我打包到生产环境运行时 浏览器提示我原因XMLHttpRequest在同步请求下 responseType不允许被设置,报错 解决办法 dist/croppper.js 注释掉 // xhr.responseType = 'arraybuffer'; xhr.withCredentials = element.crossOrigin === 'use-credentials'; xhr.send(); 然后再这个方法里加上 stringToArrayBuffer方法 xhr.onload = function () { _this.read(stringToArrayBuffer(xhr.response)); };
function stringToArrayBuffer(str) { var buf = new ArrayBuffer(str.length); var bufView = new Uint8Array(buf);
}