https://github.com/lei1248276/vue-use-print
Vue3 based browser local printing or async template printing(基于vue3的浏览器局部打印或模板/异步模板打印)
https://github.com/lei1248276/vue-use-print
local-print print template-print typescript vue3
Last synced: about 1 month ago
JSON representation
Vue3 based browser local printing or async template printing(基于vue3的浏览器局部打印或模板/异步模板打印)
- Host: GitHub
- URL: https://github.com/lei1248276/vue-use-print
- Owner: lei1248276
- License: mit
- Created: 2023-06-21T07:50:33.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-06-22T06:50:04.000Z (almost 2 years ago)
- Last Synced: 2024-11-07T18:58:28.100Z (7 months ago)
- Topics: local-print, print, template-print, typescript, vue3
- Language: Vue
- Homepage: https://www.npmjs.com/package/vue3-use-print
- Size: 69.3 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# vue-use-print
Vue based browser local printing or async template printing(基于vue的浏览器局部打印或模板/异步模板打印)## Preview
- [vue3-use-print](https://use-print.vercel.app)
- [vue3-use-print -- 国内网址](https://print.osrc.com)## Install
```bash
yarn add vue3-use-print
```## Usage
```typescript
/**
* @param dom DOM元素
* @param options.before 打印之前回调
* @param options.after 打印之后回调
*/
export default function usePrint(
dom: HTMLElement,
options?: {
before?: Function;
after?: Function;
}
): void;
/**
* @param component vue组件
* @param props 组件props
* @param options.before 打印之前回调
* @param options.after 打印之后回调
* @param options.timeout 打印超时时间
*/
export default function usePrint(
component: ReturnType,
props?: Record,
options?: {
before?: Function;
after?: Function;
timeout?: number;
}
): void;
``````vue
import { shallowRef, defineAsyncComponent } from 'vue'
import usePrint from 'vue3-use-print'
import LocalTemp from './template/LocalTemp.vue'
import ComponentTemp from './template/ComponentTemp.vue'
const AsyncCompTemp = defineAsyncComponent(() => import('./template/AsyncCompTemp.vue'))const localTempRef = shallowRef()
local print(局部打印)
component print(模板打印)
async print(异步模板打印)
```