I am currently working on integrating the Zebra BrowserPrint-1.0.4.js into Vue. You can find the code snippet at the following link: https://gist.github.com/robinsk/a667a490b7ef8192bbb9fcfc87f15757
However, I am facing an issue when trying to save the object.
mounted() {
this.zebraDefaultDevice();
},
methods: {
zebraDefaultDevice() {
BrowserPrint.getDefaultDevice('printer', function (printer) {
if ((printer != null) && (printer.connection != undefined)) {
console.log(printer);
this.selectedPrinter = printer;
};
});
},
}
The console.log function successfully gives me the required printer object.
t.Device {name: "29j164701943", deviceType: "printer", connection: "usb", uid: "29j164701943", version: 2, ...}
However, when I try to save the object with this.selectedPrinter, I encounter the following error message:
Uncaught TypeError: Cannot set property 'selectedPrinter' of undefined
I also attempted to save it into a global variable.
window.selectedPrinter
Unfortunately, when I attempt to access the variable outside the function, it returns null.
I would appreciate any assistance in resolving this issue.