前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >富文本编辑器 tinymce 的使用

富文本编辑器 tinymce 的使用

作者头像
tianyawhl
发布2020-08-14 09:51:56
1.6K0
发布2020-08-14 09:51:56
举报
文章被收录于专栏:前端之攻略前端之攻略

一款简洁表格功能齐全的富文本编辑器,表格编辑有比较强大的功能,支持获取html,设置只读功能

1、安装 tinymce

npm install tinymce --save

2、安装 @packy-tang/vue-tinymce

npm install @packy-tang/vue-tinymce

3、 复制 node_modules/tinymce目录下所有文件至public/static目录下

4、public里面的index.html文件 引入

<script src = "/static/tinymce/tinymce.min.js" > < /script>

新建tinymce.vue文件

代码语言:javascript
复制
<template>
  <div>
    <div v-html="content"></div>
    <el-button @click="handleClick">click</el-button>
    <!-- App -->
    <div>
      <vue-tinymce v-model="content" :setup="setup" :setting="setting" />
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      content: '<table style="border-collapse: collapse; width: 100%;height:35px;" border="1"><tbody><tr><td>this is p1</td><td>this is p2</td></tr></tbody></table>',
      setting: {
        readonly: false,
        menubar: false,
        toolbar:
          "undo redo | fullscreen | formatselect alignleft aligncenter alignright alignjustify | link unlink | numlist bullist | image media table | fontselect fontsizeselect forecolor backcolor | bold italic underline strikethrough | indent outdent | superscript subscript | removeformat |",
        toolbar_drawer: "sliding",
        quickbars_selection_toolbar:
          "removeformat | bold italic underline strikethrough | fontsizeselect forecolor backcolor",
        plugins: "link image media table lists fullscreen quickbars",
        language_url: "/static/tinymce/langs/zh_CN.js", // 语言包的路径
        language: "zh_CN",
        height: 350
      }
    };
  },

  methods: {
    handleClick() {
      console.log(this.content);
    },
    setup(editor) {
      console.log(editor);
    }
  }

};
</script>

 效果图

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1、安装 tinymce
  • 2、安装 @packy-tang/vue-tinymce
  • 3、 复制 node_modules/tinymce目录下所有文件至public/static目录下
  • 4、public里面的index.html文件 引入
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档