图像标记是一种客户端图像编辑组件,可让您裁剪图像并在图像上绘制文本,形状和笔触。
2020年9月3日
# Yarn
$ yarn add vue-image-markup
# NPM
$ npm i vue-image-markup --save
1.导入图像标记。
import Editor from 'vue-image-markup';
2.将图像标记添加到应用程序。
<Editor :canvasWidth="Width" :canvasHeight="Height" ref="editor" :editorId="1" />
3.启用编辑模式:
mounted() {
$this.$refs.editor.set(this.editor.mode,this.editor.options);
}
4.方法。
// 设置图片
this.$refs.editor.uploadImage(e)
// 保存图片为base64格式
this.$refs.editor.saveImage()
// 清除
this.$refs.editor.clear()
// 撤销
this.$refs.editor.undo()
// 重做
this.$refs.editor.redo()
// 按id获取对象
this.$refs.editor.getObjectsById('title')