vue+富文本编辑


前言

wangEditor —— 轻量级 web 富文本编辑器,配置方便,使用简单。
官网:www.wangEditor.com
文档:www.wangeditor.com/doc
源码:github.com/wangeditor-team/wangEditor


代码如下(示例):
   <div id="contentPost" class="contentPost"></div>

  data(){
   return{
      formLog: {
          content: "",//内容
          content_text: "",//纯文本内容即不包含图片布局样式相关代码的内容
      },
          editor: null,
   }
  }
   mounted(){
      this.initEditor();
   }
   methods:{
      initEditor() {
      this.$nextTick(() => {
        if (!this.editor) {
          this.editor = new window.wangEditor("#contentPost");
          this.editor.config.height = 580;
          this.editor.config.showFullScreen = false;
          this.editor.config.menus = this.menus;
          this.editor.config.uploadImgMaxSize = 1024 * 1024; //图片限制1M
          this.editor.config.uploadImgAccept = ["jpg", "jpeg", "png"];
          this.editor.config.uploadImgServer = "";//上传地址
          this.editor.config.uploadFileName = "file";
          this.editor.create();
        }
      });
    },
    //发布富文本编辑的内容
    submit(){
      this.formLog.content = this.editor.txt.html();
      this.formLog.content_text = this.editor.txt.text();
    }
   }
  //销毁编辑器
    this.editor.destroy()
    this.editor = null
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值