vue2.0中引入wangEditor2 步骤与坑
生活随笔
收集整理的這篇文章主要介紹了
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
this.editor = new WangEditor('#WangEditor')方可生效
.w-e-menu{z-index: 2 !important; }.w-e-text-container{z-index: 1 !important;} 注:w-e-menu的z-index必須比container的大,不然選擇菜單欄選項時,會選不上
總結
以上是生活随笔為你收集整理的vue2.0中引入wangEditor2 步骤与坑的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C语言头文件的作用
- 下一篇: 3星|《数据思维:从数据分析到商业价值》