Quasar project use Epson ePOS SDK for JavaScript to print!
-
Hi, I’m trying to use the Epson ePOS SDK for JavaScript for my Quasar project;
the SDK is an IIFE, something like jQuary and expose an object of epson to browser’s window(function(window, undefined) { .... .... if (!window.epson) { window.epson = {}; } window.epson.ePOSDevice = ePOSDevice; window.epson.ePOSDeviceConfiguration = ePOSDeviceConfiguration; })(window)
in the browser, the Epson manual says to use it in a HTML script tag:
Scripts are embedded into Web pages using HTML <script> tags. Embedding Example <script type="text/javascript" src="epos-2.14.0.js"></script>
My question is how to use this SDK in the Quasar project ?
-
You can add the script through Meta plugin https://quasar.dev/quasar-plugins/meta
Then, I would do a boot file ton inject something like $printer into the app
export default async ({ Vue }) => { Vue.mixin({ computed: { $printer () { return { ePOSDevice: ePOSDevice, ePOSDeviceConfiguration: ePOSDeviceConfiguration } } } }) }
Then in any vue component, you’ll able to access it like “this.$printer”