说明
在某些场景需要获取打印台窗口状态时,devtools-detector可以作为解决方案。
github地址:https://github.com/sindresorhus/devtools-detect#readme
使用
vue项目直接在main.js中加入
import { addListener, lanuch } from 'devtools-detector'
// 1. add listener
addListener(
// eslint-disable-next-line no-return-assign
isOpen =>
(isOpen ? location.href = '/' : '')
)
// 2. lanuch detect
lanuch()