Print.js 打印指定项

JavaScript   2024-11-25 17:46   172   0  
const handlePrintTriage = () => {
  const printRef = triageFormRef.value.backPrintRef()
  if (printRef) {
    const printWindow = window.open('', '_blank')
    printWindow.document.write(`<html>
        <head>
          <title></title>
          <style>
            body { font-family: Arial, sans-serif }
          </style>
        </head>
        <body>${printRef.innerHTML}</body>
      </html>`)
    printWindow.document.close()
    printWindow.print()
    printWindow.close()
  } else {
    ElMessage.error('未找到打印内容')
  }
}