vue中 的富文本框使用

vue中用 富文本编辑器的方法
使用npm下载:npm install wangeditor (注意 wangeditor  全部是小写字母
然后在需要使用的页面复制以下代码  

<div id="editorElem" style="text-align:left"></div>
<button v-on:click="getContent">发表</button>
在script中

import from 'wangeditor';
export default {
 name: 'editor',
 data () {
 return {
 editorContent: ''
 }
 },
 methods: {
 getContent: function () {
 console.log(this.editorContent);
 }
 },
 mounted() {
 var editor = new E('#editorElem');
 editor.customConfig.onchange = (html) => {
 this.editorContent = html
 };
 editor.create()
 }
}
效果如下图


posted @ 2017-12-19 22:11  余生我是你的眼  阅读(6322)  评论(2编辑  收藏  举报