【发布时间】:2021-08-07 22:42:01
【问题描述】:
我收到以下错误。问题是“这个”的功能。也许你可以帮助我。谢谢;)
StatQuestionnaire.html:5 错误类型错误:无法读取未定义的属性“isAvailable”
在 Channel.webpackJsonp.1020.StatQuestionnaire.onDeviceReady (main.js:1049)
在 Channel.subscribe (cordova.js:772)
在 document.addEventListener (cordova.js:129)
在 HTMLDocument.document.addEventListener (cordova.js:1694)
在 StatQuestionnaire.webpackJsonp.1020.StatQuestionnaire.printStatSite (main.js:1033)
在 Object.eval [as handleEvent] (StatQuestionnaire.html:5)
在handleEvent (vendor.js:13512)
在 callWithDebugContext (vendor.js:14804)
在 Object.debugHandleEvent [as handleEvent] (vendor.js:14392)
在 dispatchEvent (vendor.js:10412)`
private myPrinter: Printer;
private browser: boolean = true;
private content: string;
constructor(public navCtrl: NavController, public navParam: NavParams, public httpProv: HttpProvider,
public alertCtrl: AlertController , public loadingCtrl: LoadingController, public printer: Printer) {
super(httpProv, alertCtrl);
this.currQuest = this.navParam.data.questionnaire;
this.myPrinter = printer;
this.fullTime = true;
window.onresize = (e) => {
this.startPlotShowing();
}
}
printStatSite() {
...
document.addEventListener('deviceready', this.onDeviceReady, false);
if(this.browser) {
var win = window.open('','','width=3508,height=2480,toolbar=0,scrollbars=0,status=0');
win.document.write(this.content);
win.document.close();
win.print();
}
}
onDeviceReady() {
this.browser = false;
let options: PrintOptions = {
name: 'Fragebogen Auswertung',
landscape: true
}
var isAvailable: boolean = true;
this.myPrinter.isAvailable().then((result) => {isAvailable = true;}, (result) => {isAvailable = false;});
if(isAvailable) {
this.myPrinter.pick();
this.myPrinter.print(this.content, options);
} else {
console.log("Checks whether the device is capable of printing/Checks if the printer service is available (iOS) or if printer services are installed and enabled (Android).");
}
}
}
【问题讨论】:
标签: typescript cordova ionic-framework