---
outline: deep
---
# Screenshot API Examples
本页是介绍`@pear-rec/screenshot` 插件的`API`例子
本插件提供了截图插件。
## 安装
```js
import "@pear-rec/screenshot";
import "@pear-rec/screenshot/lib/style.css";
```
## screenshot 截图插件
### 效果展示
在线示例: DEMO
- https://027xiguapi.github.io/pear-rec/screenshot/demo.html
### 完整代码
```js
import React, { ReactElement, useCallback } from "react";
import Screenshots from "@pear-rec/screenshot";
import "@pear-rec/screenshot/lib/style.css";
import "./app.scss";
import imageUrl from "/imgs/th.webp";
export default function App() {
const onSave = useCallback((blob, bounds) => {
console.log("save", blob, bounds);
if (blob) {
const url = URL.createObjectURL(blob);
console.log(url);
window.open(url);
}
}, []);
const onCancel = useCallback(() => {
console.log("cancel");
}, []);
const onOk = useCallback((blob, bounds) => {
console.log("ok", blob, bounds);
if (blob) {
const url = URL.createObjectURL(blob);
console.log(url);
window.open(url);
}
}, []);
return (
);
}
```