Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

!!使用时各种常见问题 #16

Open
CcSimple opened this issue Jul 29, 2022 · 0 comments
Open

!!使用时各种常见问题 #16

CcSimple opened this issue Jul 29, 2022 · 0 comments
Labels
question Further information is requested

Comments

@CcSimple
Copy link
Owner

CcSimple commented Jul 29, 2022

1.打印重叠或者样式问题

// 在index.html 名称必须为 print-lock.css 
<link rel="stylesheet" type="text/css" media="print" href="https://cdn.jsdelivr.net/npm/vue-plugin-hiprint@latest/dist/print-lock.css">
// 也可为相对链接/自有链接 eg: public/print-lock.css
<link rel="stylesheet" type="text/css" media="print" href="/print-lock.css">

2.修改默认配置 或者 显示/隐藏元素设置参数

import { hiprint } from 'vue-plugin-hiprint'
// 还原配置
hiprint.setConfig()
// 替换配置  相关配置可控制台输入 window.HIPRINT_CONFIG 查看
hiprint.setConfig({})

3.连接客户端/不自动连接客户端

import {autoConnect, disAutoConnect} from 'vue-plugin-hiprint'
// autoConnect(); // 默认会自动连接
disAutoConnect(); // 取消自动连接

4.连接局域网内其他客户端

import { hiprint } from 'vue-plugin-hiprint'
hiprint.hiwebSocket.setHost("http://192.169.0.6:17521")
// 或者
window.hiwebSocket.setHost("http://192.169.0.6:17521")

5.打印回调问题

// 浏览器预览打印
hiprintTemplate.print(this.printData, {}, {
  callback: () => {
    // 浏览器不同, 无法监听是点了 ‘打印’ 还是 ‘取消’
    console.log('浏览器打印窗口已打开')
  }
})
// 直接打印
hiprintTemplate.print2(printData, {printer: '打印机名称', title: '打印标题'})
hiprintTemplate.on('printSuccess', function (data) {
  console.log('打印完成')
})
hiprintTemplate.on('printError', function (data) {
  console.log('打印失败')
})
@CcSimple CcSimple added the question Further information is requested label Jul 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant