vue-html5-editor 使用

安裝      npm install vue-html5-editor

在main.js中 

import VueHtml5Editor from 'vue-html5-editor'
import '../src/assets/css/font-awesome.min.css'  //引入樣式  需要單獨下載
import oedit from './components/initHTMLEditor.js' //引入配置文件

Vue.use(VueHtml5Editor, oedit)  

在 ***.vue 中

<vue-html5-editor :content="content" @change="updateData"  :height="500"  :z-index="1000" :auto-height="true" :show-module-name="false"></vue-html5-editor>

methods: { 
        updateData(e) {  // 把所有傳入的圖片都統一成寬度100%; 防止用戶上傳圖片過大
            this.content = e;
            console.info(e);
            let c1 = e.replace(/<img width="100%"/g, "<img");
            let c2 = c1.replace(/<img/g, '<img width="100%"');
            this.content = c2;
        }
    }

雖然可以做圖文混排,不過在手機上依舊是操作困難。

個人建議:還是儘量在電腦端做上傳,手機瀏覽。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章