mavon-editor 使用方法以及回顯


    <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插入到文檔中
      });
    },

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM