# ImageGenerator 图片生成
# 引入
import PressImageGenerator from 'press-plus/press-image-generator/press-image-generator';
export default {
components: {
PressImageGenerator,
}
}
# 代码演示
# 基础用法
<PressImageGenerator>
<div style="margin: 20px">
hello guowangyang
</div>
</PressImageGenerator>
# API
# Props
| 参数 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| auto-generate | 自动生成,否则调用 generate 方法手动生成 | boolean | true |
| auto-replace | 生成图片后,移除原有DOM节点,默认处理 | boolean | true |
| image-format | 图片格式 | string | image/png |
| quality | 图片质量 | number | 1 |
| loading-mask-color | loading 层颜色,即生成图片时遮罩的颜色 | string | #eddeb3 |
| html2canvas-options | html2canvas 选项 | object | - |
| 是否锯齿处理 | disable-smoothing | boolean | true |
html2canvasOptions 默认选项
{
useCORS: true,
backgroundColor: null,
logging: false,
allowTaint: false,
x: '', // fix ios ui webkit 内核生成图片透明问题
y: '',
scale: window.devicePixelRatio > 2 ? 2 : window.devicePixelRatio,
}
# Events
| 事件名 | 说明 | 参数 |
|---|---|---|
| success | 生成成功 | dataUrl |
| error | 生成失败 | error |
← DebugPopup LivePlayer →