前幾天在做一個專案中需要用富文本編輯器,最終選定用Ueditor編輯器,從官網下載原始碼(http://ueditor.baidu.com/website/download.html),按照檔案創建demo,如下:
1 <!DOCTYPE HTML> 2 <html lang="en-US"> 3 4 <head> 5 <meta charset="UTF-8"> 6 <title>ueditor demo</title> 7 </head> 8 9 <body>10 <!-- 加載編輯器的容器 -->11 <script id="container" name="content" type="text/plain">12 這里寫你的初始化內容13 </script>14 <!-- 組態檔 -->15 <script type="text/javascript" src="ueditor.config.js"></script>16 <!-- 編輯器原始碼檔案 -->17 <script type="text/javascript" src="ueditor.all.js"></script> 18 19 <!-- 實體化編輯器 -->20 <script type="text/javascript">21 var ue = UE.getEditor('container',{22 //這里可以選擇自己需要的工具按鈕名稱,此處僅選擇如下五個23 toolbars: [['FullScreen', 'Source', 'Undo', 'Redo', 'Bold', 'test']],24 //focus時自動清空初始化時的內容25 autoClearinitialContent: true,26 //關閉elementPath27 elementPathEnabled: false,28 //默認的編輯區域高度29 initialFrameHeight: 300,30 //最大輸入字數31 maximumWords:50032 });33 </script>34 </body>35 36 </html>
運行demo,結果編輯器加載不全,下載的原始碼中缺少ueditor.all.js檔案,這個簡單,查看官方提供的演示demo,瀏覽器除錯獲得整個ueditor.all.js的代碼,在本地創建js檔案,復制,保存,重繪demo,本以為這樣就可以了,現實往往喜歡和你開玩笑~demo沒有加載編輯器的樣式!!!!
功夫不負有心人啊,最后找到這樣一處配置,在ueditor.all.js檔案中查找ueditor.css,把這個檔案的路徑修改正確就OK了,希望能幫到遇到同樣問題的小伙伴們,
UE.ui.Editor = function (options) { var editor = new UE.Editor(options); editor.options.editor = editor; utils.loadFile(document, { href:editor.options.themePath + editor.options.theme + "/_css/ueditor.css", tag:"link", type:"text/css", rel:"stylesheet" });
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/2949.html
標籤:ASP.NET
上一篇:表的透視變換
下一篇:Net專案添加 WebAPI
