diff --git a/index.html b/index.html index 030a6ff51bfc6f6adcc472f6d8c02db92ce947a8..af691077f5790a358f9dda82a5a5687d32530add 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,9 @@ - Vite App + + + 打印
diff --git a/package.json b/package.json index 101d887fbb912d8980276a58b84eb565f9ac7eb6..16e3215f5dd1c9d3481a38acbc8823afc8fe3b8a 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ "guess": "^1.0.2", "vue": "^3.2.37", "jsbarcode": "^3.11.6", - "vue-html-to-paper":"^2.0.3" + "vue-html-to-paper":"^2.0.3", + "print-js":"^1.6.0" }, "devDependencies": { "@vitejs/plugin-vue": "^3.0.1", diff --git a/src/components/HelloWorld.vue b/src/components/HelloWorld.vue index eb0b61b184f8a0922e87fd017ca09f91fb1fdc5e..2975939e9034a300a0288970baaa659ae22cc493 100644 --- a/src/components/HelloWorld.vue +++ b/src/components/HelloWorld.vue @@ -1,64 +1,9 @@ \ No newline at end of file diff --git a/src/main.js b/src/main.js index a2506294bcc8223c4cf7f39c5cad5d6aa27fae4b..37c0642f2cbd426b099d5c139ed7630673d90652 100644 --- a/src/main.js +++ b/src/main.js @@ -5,4 +5,26 @@ import 'element-plus/dist/index.css' import './assets/main.css' -createApp(App).use(ElementPlus).mount('#app') +import VueHtmlToPaper from 'vue-html-to-paper'; + +const options = { + name: '_blank', + specs: [ + 'fullscreen=yes', + 'titlebar=yes', + 'scrollbars=yes' + ], + styles: [ + 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css', + 'https://unpkg.com/kidlat-css/css/kidlat.css' + ], + timeout: 100000, // default timeout before the print window appears + autoClose: false, // if false, the window will not close after printing + windowTitle: '打印', // override the window title +} + + +createApp(App) +.use(ElementPlus) +.use(VueHtmlToPaper, options) +.mount('#app')