vue使用wangeditor(轻量级富文本框)
程序员文章站
2022-05-29 23:12:59
...
vue使用wangeditor(轻量级富文本框)
npm install wangeditor //安装 wangeditor 依赖
组件中使用:
<template>
<div id="articleAdmin">
<div id="editor"></div>
<Button class="btn" @click="getContent()" type="info">发布</Button>
<Button class="btn" type="info">保存到草稿箱</Button>
</div>
</template>
<script>
import E from "wangeditor"; //引入wangeditor
import $ from "jquery"; //这里我使用了jquery
export default {
data() {
return {
articleTitle: "",
content: ""
};
},
methods: {
getContent() {
var myContent = $(".w-e-text").html();
console.log("编辑:", myContent);
}
},
mounted() {
//使用wangeditor
var editor = new E("#editor");
editor.create();
}
};
</script>
效果:
详见官网:www.wangEditor.com文档说明