<div class="bianji markdown-body">
          <mavon-editor
            ref="md"
            @change="handleMarkdownChange"
            @imgAdd="handleEditorImgAdd"
            @imgDel="imgDel"
            :ishljs="true"
            v-model="form.doc"
          />
        </div>

import { mavonEditor } from "mavon-editor";
import "mavon-editor/dist/css/index.css";
 
 

 

主要点为:图片上传在不经过处理时,maveonEditor 会将其转换成base64图,当再次请求到图片回显时,会是一大段的base64的代码,所以上传图片时要先上传的到服务器,拿到服务器图片链接,这样回显时也会是图片链接。

  handleEditorImgAdd(pos, file){
     var newdate = new FormData();
      newdate.append("file", file);
      pushFileUnload(newdate).then((res) => {  //图片上传到服务器返回图片url 链接
        console.log(res);
        this.$refs.md.$img2Url(pos, res.data.url);  //通过ref插入到文档中
      });
    },

 

相关文章:

  • 2021-12-05
  • 2021-10-16
  • 2021-09-17
  • 2021-12-10
  • 2021-08-06
  • 2018-04-13
  • 2020-01-06
猜你喜欢
  • 2021-11-04
  • 2021-10-25
  • 2021-06-30
  • 2021-11-07
  • 2021-09-25
  • 2021-11-23
  • 2021-05-17
  • 2021-11-18
相关资源
相似解决方案