vue+element ui项目总结点(三)富文本编辑器 vue-wangeditor

1.参考 https://www.npmjs.com/package/vue-wangeditor 使用该富文本编辑器

<template>
  <div class="egit_box">
    <p>富文本编辑器试用</p>
    <div class="text_box" style="width: 100%;display: flex;justify-content: center;">
      <vue-egdit ref="editor" id="editor" v-model="initContent" :menus="meaus"></vue-egdit>
    </div>
    <div class="btn" style="margin-top: 30px;">
      <el-button type="primary" @click="setContent">设置富文本内容</el-button>
      <el-button type="primary" @click="getContent">获取富文本内容</el-button>
      <el-button type="primary" @click="goNextPage">跳转页面</el-button>
    </div>
  </div>
</template>
<script>
//参考文档 https://www.npmjs.com/package/vue-wangeditor
import vueEgdit from ‘vue-wangeditor‘
export default {
  components: {
    vueEgdit
  },
  data() {
    return {
      initContent: ‘初始化富文本内容‘, //富文本催办邮件内容
      meaus: [
        ‘source‘, // 源码模式
        ‘|‘,
        ‘bold‘, // 粗体
        ‘underline‘, // 下划线
        ‘italic‘, // 斜体
        ‘strikethrough‘, // 中线
        ‘eraser‘, // 清空格式
        ‘forecolor‘, // 文字颜色
        ‘bgcolor‘, // 背景颜色
        ‘|‘,
        ‘quote‘, // 引用
        ‘fontfamily‘, // 字体
        ‘fontsize‘, // 字号
        ‘head‘, // 标题
        ‘unorderlist‘, // 无序列表
        ‘orderlist‘, // 有序列表
        ‘alignleft‘, // 左对齐
        ‘aligncenter‘, // 居中
        ‘alignright‘, // 右对齐
        ‘|‘,
        ‘link‘, // 链接
        ‘unlink‘, // 取消链接
        ‘table‘, // 表格
        ‘emotion‘, // 表情
        ‘|‘,
        ‘img‘, // 图片
        ‘video‘, // 视频
        ‘insertcode‘, // 插入代码
        ‘|‘,
        ‘undo‘, // 撤销
        ‘redo‘, // 重做
        ‘fullscreen‘ // 全屏
      ]
    }
  },
  mounted() {
    console.log(this.$refs.editor, ‘富文本实例‘)
  },
  methods: {
    setContent() {
      this.initContent = ‘设置好的内容‘;
      this.$refs.editor.setHtml(this.initContent) //如设置:后台返回来的固定模板
      console.log(this.initContent, ‘设置编辑器内容‘)
    },
    getContent() {
      this.initContent = this.$refs.editor.getHtml(this.initContent);
      console.log(this.initContent, ‘获取编辑器当前内容的html代码片段‘)
    },
    //vue 跳转
    goNextPage() {
      this.$router.push({
        name: ‘testEgdit‘,
      })
    }
  }
}

</script>

原文地址:https://www.cnblogs.com/lhl66/p/10109772.html

时间: 2024-08-12 00:26:02

vue+element ui项目总结点(三)富文本编辑器 vue-wangeditor的相关文章

vue+element ui项目总结点(一)select、Cascader级联选择器、encodeURI、decodeURI转码解码、一级mockjs用法、路由懒加载三种方式

不多说上代码: <template> <div class="hello"> <h1>{{ msg }}</h1> <p>Element UI简单Cascader级联选择器使用</p> <el-cascader :options='options' v-model="selectedOptions" @change="handleChange"> </el-

在 Vue 项目中引入 tinymce 富文本编辑器

项目中原本使用的富文本编辑器是 wangEditor,这是一个很轻量.简洁编辑器 但是公司的业务升级,想要一个功能更全面的编辑器,我找了好久,目前常见的编辑器有这些: UEditor:百度前端的开源项目,功能强大,基于 jQuery,但已经没有再维护,而且限定了后端代码,修改起来比较费劲 bootstrap-wysiwyg:微型,易用,小而美,只是 Bootstrap + jQuery... kindEditor:功能强大,代码简洁,需要配置后台,而且好久没见更新了 wangEditor:轻量.

vue2.0项目中使用Ueditor富文本编辑器示例

最近在vue项目中需要使用富文本编辑器,于是将Ueditor集成进来,作为公共组件.在线预览:https://suweiteng.github.io/vue2-management-platform/#/editor项目地址:https://github.com/suweiteng/vue2-management-platform 记得在右上角点个赞哦~ 1.放入静态资源并配置 首先把官网下载的Ueditor资源,放入静态资源src/static中.修改ueditor.config.js中的wi

WEB项目中使用UEditor(富文本编辑器)

Ueditor富文本编辑器是在很多项目里经常用到的框架,是百度开发团队开发的一款很好用的富文本编辑器 下面就是我在一个系统里用到的,有了富文本编辑器,管理员使用起来不是很方便? 所以本博客介绍这个富文本编辑器的使用哈!觉得写得不错的请点赞哈,有建议欢迎提哈!^V^ 下载链接:http://ueditor.baidu.com/website/download.html 具体的使用请看官网:http://ueditor.baidu.com/website/index.html 下载富文本编辑器后,我

给vue添加一个超级好用的富文本编辑器 markdown

用过百度富文本编辑器ueditor,还用过Ttinymce编辑器,都感觉很一般,最近看到一个超级好用的富文本,除了普通富文本的这些功能,还可以直接在编辑器上输入代码来写页面.左边写内容,右边看效果,也就是相当于可视化编辑器. 好了,废话不多说,直接开始吧. 首先第一步肯定是安装了: 命令行工具输入: npm install mavon-editor --save 第二步,引入markdown组件 和 注册markdown组件 引入: import {mavonEditor} from "mavo

django项目中使用KindEditor富文本编辑器

先从官网下载插件,放在static文件下 前端引入 <script type="text/javascript" src="/static/back/kindeditor/kindeditor-all.js"></script> <script> KindEditor.ready(function (K) { window.editor = K.create('#content', { {# 加上这句话可以使jquery能获取到富

vue2.0项目中使用Ueditor富文本编辑器应用中出现的问题

1.如何设置config中的内容 readonly:true,//只读模式wordCount:false,//是否开启字数统计enableAutoSave: false,//自动保存功能 重点:enableAutoSave不一定生效,怎么办? ueditor.config.js文件中设置enableAutoSave参数为false就可以关闭本地保存功能. //启用自动保存 ,enableAutoSave: false ueditor1.4.3版本是没有效果的,需要修改代码,在ueditor1.5

Vue项目增加TinyMec富文本编辑器组件

TinyMec富文本编辑器开源,而且开发人员对他的支持比较好,所以选用了它 https://liubing.me/vue-tinymce-5.html 基于Vue CLI 3脚手架搭建的项目整合tinymce 5富文本编辑器,vue cli 2版本及tinymce 4版本参考:https://blog.csdn.net/liub37/article/details/83310879做了些小修改,详情见github Github:https://github.com/liub1934/vue-us

vue中引入Tinymce富文本编辑器

最近想在项目上引入一个富文本编辑器,之前引入过summernote,感觉并不太适合vue使用, 然后在网上查了查,vue中使用Tinymce比较适合, 首先,我们在vue项目的components文件夹中加入如下几个文件 首先看一下Tinymce/dynamicLoadScript.js的内容: let callbacks = [] function loadedTinymce() { // to fixed https://github.com/PanJiaChen/vue-element-a