日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > vue >内容正文

vue

vue2.0中引入wangEditor2 步骤与坑

發布時間:2025/6/15 vue 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 vue2.0中引入wangEditor2 步骤与坑 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
  • 安裝:官方給出了如下安裝方式
    點擊 https://github.com/wangfupeng1988/wangEditor/releases 下載最新版 使用git下載: git clone https://github.com/wangfupeng1988/wangEditor.git 使用npm安裝: npm install wangeditor (注意 wangeditor 全部是小寫字母) 使用bower下載:bower install wangEditor (前提保證電腦已安裝了bower)在vue2.0項目中直接 npm install wangeditor --save
  • 在頁面中放入
    <div id="editor"></div>然后
    import WangEditor from 'wangeditor' let that = this this.editor = new WangEditor('#WangEditor') //這個地方傳入div元素的id 需要加#號// 配置 onchange 事件 this.editor.change = function () { // 這里是change 不是官方文檔中的 onchange// 編輯區域內容變化時,實時打印出當前內容console.log(this.txt.html()) } this.editor.create() // 生成編輯器 this.editor.txt.html('<p>輸入內容...</p>') //注意:這個地方是txt 不是官方文檔中的$txt
  • 在開發中碰到過這么個問題,就是在用v-if動態顯示隱藏頁面元素時,頁面會進行重繪,目標元素div依然存在于dom樹中,但是wanEditor實例需要重新生成,且需要在this.$nextTick方法中調用
    this.editor = new WangEditor('#WangEditor')方可生效
  • wangEditor的輸入控制欄與輸入區域默認的z-index為100001 10000,當富文本編輯框上方有下拉菜單時,選擇框會被覆蓋。解決辦法
    .w-e-menu{z-index: 2 !important; }.w-e-text-container{z-index: 1 !important;} 注:w-e-menu的z-index必須比container的大,不然選擇菜單欄選項時,會選不上
  • 總結

    以上是生活随笔為你收集整理的vue2.0中引入wangEditor2 步骤与坑的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。