42 lines
1.2 KiB
Plaintext
42 lines
1.2 KiB
Plaintext
<template>
|
||
<div>
|
||
<div class="n-layout-page-header">
|
||
<a-card :bordered="false" title="打印场景"> json打印表格,图片打印 </a-card>
|
||
</div>
|
||
<a-card :bordered="false" class="mt-4 proCard">
|
||
<a-space>
|
||
<a-button type="primary" @click="jsonPrint">打印表格</a-button>
|
||
<a-button type="primary" @click="imagePrint">打印图片</a-button>
|
||
</a-space>
|
||
</a-card>
|
||
</div>
|
||
</template>
|
||
|
||
<script lang="ts" setup>
|
||
import printJS from 'print-js';
|
||
|
||
function jsonPrint() {
|
||
printJS({
|
||
printable: [
|
||
{ name: '汪伟', email: '735869@gmail.com', phone: '186****5653' },
|
||
{ name: '雷秀英', email: '235656452@gmail.com', phone: '135****6536' },
|
||
{ name: '邹芳', email: '24586526@gmail.com', phone: '159****5869' },
|
||
],
|
||
properties: ['name', 'email', 'phone'],
|
||
type: 'json',
|
||
});
|
||
}
|
||
|
||
function imagePrint() {
|
||
printJS({
|
||
printable: [
|
||
'https://naive-ui-admin-docs.vercel.app/logo.png',
|
||
'https://naive-ui-admin-docs.vercel.app/logo.png',
|
||
],
|
||
type: 'image',
|
||
header: 'Multiple Images',
|
||
imageStyle: 'width:100%;',
|
||
});
|
||
}
|
||
</script>
|