第一步 安装
npm install vue2-editor
yarn add vue2-editor
页面引入
import { VueEditor } from "vue2-editor";
import { VueEditor, Quill } from "vue2-editor";
插入图片 及 正常回显
<vue-editor id="editor" useCustomImageHandler @image-added="handleImageAdded" v-model="htmlForEditor"> </vue-editor>
export default {
components: {
VueEditor
},
data() {
return {
htmlForEditor: "",
}
},
methods: {
handleImageAdded(file, Editor, cursorLocation, resetUploader) {
var formData = new FormData();
formData.append("file", file);
formData.append('systemId', this.$store.state.user.systemId)
axios({
url: `${process.env.VUE_APP_UPLOAD_URL}`,
method: "POST",
data: formData
})
.then(result => {
console.log(result, '来了吗')
let url = result.data.data.url;
Editor.insertEmbed(cursorLocation, "image", url);
Editor.setSelection(cursorLocation + 1)
resetUploader();
})
.catch(err => {
console.log(err);
});
}
}
}
vue2-editor相关配置描述: vue2-editor事件描述:
|