亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

vuecli3.x中輕松4步帶你使用tinymce的步驟

 更新時間:2020年06月25日 09:24:04   作者:_Dreams  
這篇文章主要介紹了vuecli3.x中輕松4步帶你使用tinymce的步驟,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧

前言

筆者在使用tinymce時發(fā)現(xiàn)跟著網(wǎng)上的方法去做,基本都會因為版本等一些問題報錯,所以筆者總結(jié)了以下方案!可以收藏哦

第一步:

npm install @tinymce/tinymce-vue@3.2.2 tinymce@5.3.1 -S

第二步:

找到node_modules中的skins文件夾,然后在項目中的public下新建tinymce文件夾,然后將剛剛找到的整個skins文件夾拷貝到public的tinymce目錄下。

接著去官網(wǎng)下載語言包,解壓,將langs文件夾拷貝到public的tinymce文件夾下(和skins文件夾同級)

第三步:

在components文件夾下新建tinymce組件的文件夾,新建index.vue文件,復制以下代碼進去:

<template>
 <div class="tinymce-editor">
  <Editor
   :id="editorId"
   v-model="editorValue"
   :init="editorInit"
  />
 </div>
</template>

<script>
// 引入組件
import tinymce from 'tinymce/tinymce';
import Editor from '@tinymce/tinymce-vue';
import 'tinymce/icons/default/icons';
import 'tinymce/themes/silver';
// 引入富文本編輯器主題的js和css
import 'tinymce/themes/silver/theme.min';
import 'tinymce/skins/ui/oxide/skin.min.css';
// 擴展插件
import 'tinymce/plugins/image';
import 'tinymce/plugins/link';
import 'tinymce/plugins/code';
import 'tinymce/plugins/table';
import 'tinymce/plugins/lists';
import 'tinymce/plugins/wordcount'; // 字數(shù)統(tǒng)計插件
import 'tinymce/plugins/media';// 插入視頻插件
import 'tinymce/plugins/template';// 模板插件
import 'tinymce/plugins/fullscreen';
import 'tinymce/plugins/paste';
import 'tinymce/plugins/preview';
import 'tinymce/plugins/contextmenu';
import 'tinymce/plugins/textcolor';
export default {
 name: 'TinymceEditor',
 components: {Editor},
 props: {
  height: {
   type: Number,
   default: 500
  },
  id: {
   type: String,
   default: 'tinymceEditor'
  },
  value: {
   type: String,
   default: ''
  },
  plugins: {
   type: [String, Array],
   default: 'link lists image code table wordcount media fullscreen preview paste contextmenu textcolor'
  },
  toolbar: {
   type: [String, Array],
   default: 'fontselect | bold italic underline strikethrough | link unlink image | undo redo | fontsizeselect | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist | outdent indent blockquote | code | removeformat'
  }
 },
 data() {
  return {
   editorInit: {
    language_url: `${window.baseUrl}/tinymce/langs/zh_CN.js`,
    language: 'zh_CN',
    skin_url: `${window.baseUrl}/tinymce/skins/ui/oxide`,
    content_css: `${window.baseUrl}/tinymce/skins/content/default/content.css`,
    height: this.height,
    content_style: '* { padding:0; margin:0; } img {max-width:100% !important }',
    plugin_preview_width: 375, // 預覽寬度
    plugin_preview_height: 668,
    lineheight_val: "1 1.1 1.2 1.3 1.35 1.4 1.5 1.55 1.6 1.75 1.8 1.9 1.95 2 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 3 3.1 3.2 3.3 3.4 4 5",
    fontsize_formats: "8pt 10pt 11pt 12pt 13pt 14pt 15pt 16pt 17pt 18pt 24pt 36pt",
    font_formats:"微軟雅黑='微軟雅黑';宋體='宋體';黑體='黑體';仿宋='仿宋';楷體='楷體';隸書='隸書';幼圓='幼圓';Andale Mono=andale mono,times;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Book Antiqua=book antiqua,palatino;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier;Georgia=georgia,palatino;Helvetica=helvetica;Impact=impact,chicago;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco;Times New Roman=times new roman,times;Trebuchet MS=trebuchet ms,geneva;Verdana=verdana,geneva;Webdings=webdings;Wingdings=wingdings",
    plugins: this.plugins,
    powerpaste_word_import: 'merge',
    toolbar: this.toolbar,
    paste_data_images: true,
    statusbar: true, // 底部的狀態(tài)欄
    menubar: true, // 最上方的菜單
    branding: false, // 水印“Powered by TinyMCE”
    images_upload_handler: (blobInfo, success, failure) => {
     this.$emit('handleImgUpload', blobInfo, success, failure);
    }
   },
   editorId: this.id,
   newValue: ''
  };
 },
 watch: {
  newValue(newValue) {
   this.$emit('input', newValue);
  }
 },
 mounted() {
  tinymce.init({});
 },
 computed: {
  editorValue: {
   get() {
    return this.value;
   },
   set(val) {
    this.newValue = val;
   }
  }
 },
 methods: {
  // https://github.com/tinymce/tinymce-vue => All available events
  clear() {
   this.editorValue = '';
  }
 }
};
</script>

第四步:

在要使用的組件中加入以下代碼:

import TinymceEditor from '@/components/tinymce';

components: { //注冊TinymceEditor組件
  TinymceEditor
},

data() {
  return {
    content: '', //富文本的內(nèi)容
    baseUrl: window.baseUrl, //默認為'' 空字符串
  }
}

computed:{
  realHeight() {
   return (window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight) - 200
  }
}

methods:{
  async imgUpload(blobInfo, success, failure) {
   const formData = new FormData();
   formData.append('file', blobInfo.blob());
   try {
    const res = await uploadFile(formData);
    success(this.server + res);
    console.log(this.server + res);
   } catch (e) {
    console.log(e);
    failure('上傳失敗:' + e);
   }
  },
}
模板中使用:

<tinymce-editor
 id="editor"
 ref="editor"
 v-model="content"
 :height="realHeight"
 @handleImgUpload="imgUpload"
/>

然后就大功告成:

到此這篇關(guān)于vuecli3.x中輕松4步帶你使用tinymce的步驟的文章就介紹到這了,更多相關(guān)vuecli3.x使用tinymce內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • vue2.x中的provide和inject用法小結(jié)

    vue2.x中的provide和inject用法小結(jié)

    這篇文章主要介紹了vue2.x中的provide和inject用法小結(jié),本文通過示例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友參考下吧
    2023-12-12
  • Vue2.x中利用@font-size引入字體圖標報錯的解決方法

    Vue2.x中利用@font-size引入字體圖標報錯的解決方法

    今天小編就為大家分享一篇Vue2.x中利用@font-size引入字體圖標報錯的解決方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-09-09
  • VUE中v-model和v-for指令詳解

    VUE中v-model和v-for指令詳解

    本篇文章主要介紹了VUE中v-model和v-for指令詳解,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-06-06
  • 詳解如何使用Vue-PDF在應用中嵌入PDF文檔

    詳解如何使用Vue-PDF在應用中嵌入PDF文檔

    在現(xiàn)代Web應用中,PDF文檔的使用非常普遍,因為它可以在各種設備和操作系統(tǒng)上保持一致的外觀和格式,本文我們就來探討一下如何在Vue.js應用中使用vue-pdf庫嵌入PDF文檔吧
    2023-08-08
  • vue vuex vue-rouert后臺項目——權(quán)限路由(適合初學)

    vue vuex vue-rouert后臺項目——權(quán)限路由(適合初學)

    這篇文章主要介紹了vue vuex vue-rouert后臺項目——權(quán)限路由,通過本文可以很清除的捋清楚vue+vuex+vue-router的關(guān)系,本版本非常簡單,適合初學者,需要的朋友可以參考下
    2017-12-12
  • 從0搭建Vue3組件庫如何使用?glup?打包組件庫并實現(xiàn)按需加載

    從0搭建Vue3組件庫如何使用?glup?打包組件庫并實現(xiàn)按需加載

    這篇文章主要介紹了從0搭建Vue3組件庫如何使用?glup?打包組件庫并實現(xiàn)按需加載,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2023-03-03
  • vue購物車插件編寫代碼

    vue購物車插件編寫代碼

    這篇文章主要為大家詳細介紹了vue購物車插件的編寫代碼,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-11-11
  • 仿vue-cli搭建屬于自己的腳手架的方法步驟

    仿vue-cli搭建屬于自己的腳手架的方法步驟

    這篇文章主要介紹了仿vue-cli搭建屬于自己的腳手架的方法步驟,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2019-04-04
  • 詳解Vue 動態(tài)添加模板的幾種方法

    詳解Vue 動態(tài)添加模板的幾種方法

    本篇文章主要介紹了詳解Vue 動態(tài)添加模板的幾種方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-04-04
  • 解決Vue運算符報錯:Syntax Error: Unexpected token問題

    解決Vue運算符報錯:Syntax Error: Unexpected token問題

    這篇文章主要介紹了解決Vue運算符報錯:Syntax Error: Unexpected token問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-01-01

最新評論