欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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>

  效果:

vue使用wangeditor(轻量级富文本框)

详见官网:www.wangEditor.com文档说明