我正在开发一个离子2应用程序,其中我在for循环中使用条形码扫描程序代码,但变量i在条形码功能中无法访问..
这是我的barcodetest.ts
export class HelloIonicPage implements OnInit {
orderstring: string;
orderarray: any;
bartxt: any;
pickuplist: any;
vendorbarcode(index, pickuplist) {
this.orderstring = this.pickuplist[index].OrderId;
if (this.orderstring !== '') {
this.orderarray = this.orderstring.split(', ');
for (var i = 0; i <= this.orderarray.length; i++) {
console.log(this.orderarray[i]); //here m getting the value
BarcodeScanner.scan().then((barcodeData) => {
if (barcodeData.cancelled) {
return false;
}
console.log(this.orderarray[i]); //here getting undefined
}, (err) => {
console.log(err);
});
}
}
}
}
这是this.orderstring =&#34; 12234,12235&#34 ;;
我在某些方面尝试了这个,然后也没有得到结果..请帮我解决这个问题。