天天看點

ABP-百度ueditor富文本編輯器使用(一)

1.下載下傳ueditor富文本編輯器http://ueditor.baidu.com/website/download.html#ueditor

2.選擇适合自己的版本,将下載下傳下來的檔案包直接放至libs檔案夾下

3.導入config.js  和  all.config中

建議在Web-App-Common-Views-Layout-Layout.cshtml中引入

<script type="text/javascript" src="~/libs/ueditor/ueditor.config.js"></script>
	<script type="text/javascript" src="~/libs/ueditor/ueditor.all.js"></script>
           

這樣可以在釋出時有效避免因路徑産生的問題。

4.在使用的頁面時候調用

4.1html中使用

<script id="editor" name="content" type="text/plain" >
								
</script>
           

4.2js中使用

初始化編輯器

   ue = UE.getEditor('editor');
                    ue.ready(function () {
                        ue.setContent(vm.news.context);
         })
           

獲得編輯器内容

vm.news.context = UE.getEditor('editor').getContent();
           

銷毀編輯器,這個很重要,在離開目前頁面的時候銷毀掉編輯器,如果不銷毀此編輯器就會導緻第二次打開時,編輯器消失。

$scope.$on("$destroy", function () {
				console.log("我離開了,不要想我")
				ue.destroy();
			})
           

最後别忘了  ue一定是一個公共變量。