@quarkunlimit/qu-print
v1.0.1
Published
```tsx import { useRef } from 'react' import { quPrint } from '@quarkunlimit/qu-print'
Downloads
1
Readme
import { useRef } from 'react'
import { quPrint } from '@quarkunlimit/qu-print'
function App() {
const iframeRef = useRef()
// printHtml
const URL = ''
const onLoad = () => {
iframeRef.current = document.getElementById('iframeRef')
const data = {
hospitalName: '睿美云',
time: '2022-05-12',
newTime: '2022-05-12',
dataSource: [
{
businessType: '预收款',
totalMoney: '5000',
itemCashPay: '200',
itemCardPay: '125',
itemVirtual: '575',
itemStorePay: '100',
},
{
businessType: '预收款',
totalMoney: '4545',
itemCashPay: '57845',
itemCardPay: '1245',
itemVirtual: '445',
itemStorePay: '100',
},
],
}
quPrint.getInstance().postRender(iframeRef.current, data, '*')
}
const onClick = () => {
quPrint.getInstance().postPrint(iframeRef.current, '*')
}
return (
<div className="App">
<div>app</div>
<button onClick={onClick}>打印</button>
<iframe
onLoad={onLoad}
width={800}
height={400}
id="iframeRef"
title="iframeRef"
src={URL}
frameBorder={0}
/>
</div>
)
}
export default App