wangeditor上传图片 vue代码
时间: 2023-10-29 17:40:04 浏览: 90
vue+wangEditor的使用与展示(表格+图片自定义上传+带格式粘贴)
5星 · 资源好评率100%
<template>
<div>
<wangeditor ref="editor" :config="editorConfig" @change="handleEditorChange"></wangeditor>
<button @click="uploadImage">上传图片</button>
</div>
</template>
<script>
import WangEditor from 'wangeditor'
export default {
components: {
WangEditor
},
data() {
return {
editorConfig: {
// 配置项
}
}
},
methods: {
handleEditorChange() {
// 处理编辑器内容变化
},
uploadImage() {
const editor = this.$refs.editor
editor.uploadImg(this.handleUploadImage)
},
handleUploadImage(result) {
// 处理上传图片成功后的回调
const editor = this.$refs.editor
editor.command(null, 'insertHtml', `<img src="${result.url}" />`)
}
}
}
</script>
阅读全文