vue中用 富文本编辑器的方法
使用npm下载:npm install wangeditor (注意 wangeditor 全部是小写字母)
然后在需要使用的页面复制以下代码
<div id="editorElem" style="text-align:left"></div>
<button v-on:click="getContent">发表</button>
在script中
import E 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()
}
}
效果如下图