跳到主要内容
Tit1e

evolly.one

00About01Products02Writing03Contact04Amber

A small corner of the internet.

写软件,也留下一些文字。

← All writing

网页打印指定区域内容

2019年3月26日
  • 学习

公司业务上有打印需求,但打印内容在一个弹窗中,在网上找了一圈,找到了解决办法。

let dom = document.getElementById('content')
let win = window.open('')
win.document.write(dom.outerHTML)
win.print()

以上代码就实现了指定区域的打印功能。

参考文章

← 上一篇使用 Vue CLI3 编写组件库并发布至 npm下一篇 →编写一个全局 SVG 图标组件
© 2026 Tit1eMade with care ↗