说明:我在项目中使用XMLHttpRequest。我想在获得状态时调用另一个函数。下面是我的home.ts
代码。
onFileSelected(event)
,除非我尝试调用此函数,否则一切正常
this.callproducts(data,0,c_altcode)
请指导我如何调用此功能
home.ts
onFileSelected(event)
{
var file = event.target.files[0];
var url = window.URL.createObjectURL(file);
var oReq = new XMLHttpRequest();
oReq.open("GET", url, true);
oReq.responseType = "arraybuffer";
oReq.onload = function(e) {
var arraybuffer = oReq.response;
var data = new Uint8Array(arraybuffer);
var arr = new Array();
for (var i = 0; i != data.length; ++i) arr[i] = String.fromCharCode(data[i]);
var bstr = arr.join("");
var workbook = XLSX.read(bstr, {
type: "binary"
});
var first_sheet_name = workbook.SheetNames[0];
var worksheet = workbook.Sheets[first_sheet_name];
var final_arr = XLSX.utils.sheet_to_json(worksheet, {
raw: true
});
if(oReq.status === 200)
{
if(final_arr[0].hasOwnProperty("Altcode"))
{
var c_altcode =final_arr[0].hasOwnProperty("Altcode");
// error comming in this line.
this.callproducts(data,0,c_altcode);
}
}
}
oReq.send(null);
}
// This is my `callproducts()` which i want to call.
callproducts(data,index,srch)
{
// some code here
}
错误:类型'XMLHttpRequest'上不存在属性'callproducts'。