最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Vue中使用wangeditor富文本編輯的問題

 更新時間:2021年02月07日 11:44:41   作者:xk. 依然范特西  
這篇文章主要介紹了Vue中使用wangeditor富文本編輯的問題,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下

wangEditor是基于javascript和css開發(fā)的 Web富文本編輯器, 輕量、簡潔、易用、開源免費(fèi)。
在我們實(shí)際項目上還是比較頻繁應(yīng)用到的,下面出個案例供大家參考學(xué)習(xí)…

wangEditor文檔:https://www.wangeditor.com/

富文本編輯器截圖:

在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述

<!--富文本編輯器。http://www.wangeditor.com/
使用示例:
<AppEditor v-model="content"></AppEditor>
-->
<template>
 <article ref="editor" class="AppEditor-root"></article>
</template>
<script>
 const E = require('wangeditor');
 export default {
  name: 'AppEditor',
  model: {
   prop: 'value',
   event: 'update:value',
  },
  props: {
   // value值,v-model綁定
   value: {type: String, default: ''},
   // 菜單選項
   menus: {
    type: Array,
    default(){
     return [
      'bold', // 粗體
      'italic',//斜體
      'underline',//下劃線
      'fontSize', // 字號
      'strikeThrough',//刪除線
      'image', // 插入圖片
      'undo', // 撤銷


      // 'fontName', // 字體
      // 'italic', // 斜體
      // 'underline', // 下劃線
      // 'strikeThrough', // 刪除線
      // 'foreColor', // 文字顏色
      // 'backColor', // 背景顏色
      // 'link', // 插入鏈接
      // 'list', // 列表
      // 'justify', // 對齊方式
      // 'quote', // 引用
      // 'emoticon', // 表情
      // 'image', // 插入圖片
      // 'table', // 表格
      // 'video', // 插入視頻
      // 'code', // 插入代碼
      // 'undo', // 撤銷
      // 'redo', // 重復(fù)
     ];
    },
   },
  },
  data(){
   return {
    editor: {}, // 編輯器對象
    _value: '', // 內(nèi)容備份,用于watch時候判斷,只在編輯器輸入時改變
   };
  },
  computed: {},
  mounted(){
   this.initEditor();
  },
  watch: {
   value(newValue, oldValue){
    // 編輯器onchange更改的不處理,只處理父組件傳來的,防止文字回退bug
    if (newValue != this._value) {
     this.editor.txt.html(newValue);
    }
   },
  },
  methods: {
   initEditor(){
    let editor = new E(this.$refs.editor);
    Object.assign(editor.customConfig, {
     menus: this.menus,
     zIndex: 100,
     height: 200,
     pasteFilterStyle: false,
     onchange: (html) => {
      this._value = html; // 更新 _value
      this.$emit('update:value', html); // 更新 value
     },
     customUploadImg:((file, insert)=> {
      if(this.$utils.isEmpty(file)){
       return;
      }
      const msg = this.$Message.loading({
       content: '親,圖片正在拼命地上傳中,請稍等...',
       duration: 0
      });
      var params = new FormData();
      params.append('img', file[0]);
      this.$api.post('/synthesis/crm/picture/pictureUpload',params).then(res => {
       insert(res.data.imgUrl)
       setTimeout(msg, 0);
       this.$Message.success('上傳成功');
      })
     }),
     uploadImgHooks:{

      customInsert: function (insertImg, result, editor) {
       insertImg(result.url)
      }
     }
    });


    editor.create();
    editor.txt.html(this.value); // 針對數(shù)據(jù)異步獲取的這里無法立即綁定,在watch判斷處理
    this.editor = editor;
   },
  },
 };
</script>
<style scoped lang="scss">
 .AppEditor-root{ border: 1px solid #f0f0f0; height: 400px !important;
  /deep/ .w-e-toolbar{ border: none !important; border-bottom: 1px solid #f0f0f0 !important; background-color: #fff !important;

  }
  /deep/ .w-e-text-container{ height: calc(100% - 43px) !important; border: none !important; z-index:1 !important;
   .w-e-text{ height: 100%; overflow-y: auto !important;}
  }
 }

</style>

到此這篇關(guān)于Vue中使用wangeditor富文本編輯的問題的文章就介紹到這了,更多相關(guān)wangeditor富文本編輯內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • 淺談vue的iview列表table render函數(shù)設(shè)置DOM屬性值的方法

    淺談vue的iview列表table render函數(shù)設(shè)置DOM屬性值的方法

    下面小編就為大家?guī)硪黄獪\談vue的iview列表table render函數(shù)設(shè)置DOM屬性值的方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-09-09
  • Element-ui el-tree新增和刪除節(jié)點(diǎn)后如何刷新tree的實(shí)例

    Element-ui el-tree新增和刪除節(jié)點(diǎn)后如何刷新tree的實(shí)例

    這篇文章主要介紹了Element-ui el-tree新增和刪除節(jié)點(diǎn)后如何刷新tree的實(shí)例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-08-08
  • vue elementUI 表單校驗的實(shí)現(xiàn)代碼(多層嵌套)

    vue elementUI 表單校驗的實(shí)現(xiàn)代碼(多層嵌套)

    這篇文章主要介紹了vue elementUI 表單校驗的實(shí)現(xiàn)代碼(多層嵌套),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-11-11
  • 如何基于vue-cli3.0構(gòu)建功能完善的移動端架子

    如何基于vue-cli3.0構(gòu)建功能完善的移動端架子

    這篇文章主要介紹了基于vue-cli3.0構(gòu)建功能完善的移動端架子,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-04-04
  • buildAdmin開源項目引入四種圖標(biāo)方式詳解

    buildAdmin開源項目引入四種圖標(biāo)方式詳解

    這篇文章主要為大家介紹了buildAdmin開源項目引入四種圖標(biāo)方式詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-02-02
  • 最新評論

    微山县| 陕西省| 邢台市| 镇沅| 筠连县| 屯留县| 韶关市| 昌平区| 嵊泗县| 华坪县| 额尔古纳市| 秦安县| 北宁市| 洛阳市| 江口县| 都江堰市| 博野县| 富蕴县| 浑源县| 枣强县| 柏乡县| 霍林郭勒市| 独山县| 新泰市| 长岭县| 博湖县| 体育| 绥阳县| 平乐县| 无锡市| 临漳县| 彭山县| 定南县| 新余市| 兴城市| 镇坪县| 喜德县| 铜陵市| 闻喜县| 利川市| 且末县|