# 百度編輯器
[TOC]

## 使用
| 參數 | 說明 |
| --- | --- |
|參數一 | 表單id, |
| 參數二 | ueditor 的選項,比如可以設置按鈕類型 |
| 參數三 | 初始化后執行的回調函數 |
```
<textarea id="container" style="height:300px;width:100%;"></textarea>
<script>
require(['hdjs'], function (hdjs) {
hdjs.ueditor('container', {hash: 2, data: 'hd'}, function (editor) {
console.log(editor)
});
})
</script>
<textarea id="hdphp" style="height:300px;width:100%;"></textarea>
<script>
require(['hdjs'], function (hdjs) {
hdjs.ueditor('hdphp', {autoHeightEnabled:false,'toolbars': [['fullscreen', 'source','insertcode', 'hdimage', 'preview']]}, function (editor) {
console.log('編輯器執行后的回調方法2')
});
})
</script>
```
## 代碼高亮
以下目錄請根據自己的項目進行更改
~~~
<script src="/resource/hdjs/dist/static/package/ueditor/third-party/SyntaxHighlighter/shCore.js"></script>
<link href="https://cdn.bootcss.com/SyntaxHighlighter/3.0.83/styles/shThemeDefault.min.css" rel="stylesheet">
<script>
SyntaxHighlighter.all()
</script>
~~~
## Vue.js中使用

```
<div id="app">
<textarea id="container" style="height:300px;width:100%;" v-model="field.content"></textarea>
</div>
<script>
require(['vue','hdjs'], function (Vue,hdjs) {
var vm = new Vue({
el: '#app',
data: {
field: {content:''},
},
mounted() {
//圖文編輯器
var This = this;
hdjs.ueditor('container', {}, function (editor) {
//監聽內容更改
editor.addListener('contentChange', function () {
vm.$set(vm.field, 'content', editor.getContent());
});
//監聽vue數據
vm.$watch('field', function (item) {
if (editor && editor.getContent() != item.content) {
editor.setContent(item.content ? item.content : '');
}
});
//失去焦點時處罰
editor.addListener('blur', function () {
vm.$set(vm.field, 'content', editor.getContent());
});
editor.addListener('clearRange', function () {
vm.$set(vm.field, 'content', editor.getContent());
});
});
}
})
})
</script>
```
## AngularJs中使用
```
<script>
hdjs.ueditor('container', {}, function (editor) {
editor.addListener('contentChange', function () {
$scope.field.detail = editor.getContent();
});
editor.addListener('ready', function () {
if (editor && editor.getContent() != $scope.field.detail) {
editor.setContent($scope.field.detail);
}
$scope.$watch('field', function (item) {
if (editor && editor.getContent() != item.detail) {
editor.setContent(item.detail ? item.detail : '');
}
},true);
});
editor.addListener('clearRange', function () {
$scope.field.detail = editor.getContent();
$scope.$apply();
});
});
```
- 文檔已經遷移到后盾人
- 基礎知識
- 項目介紹
- 安裝配置
- 日期時間
- 日期選擇
- 列表框日期
- 日期區間
- 時間選擇
- moment
- 上傳處理
- 初始配置
- 圖片上傳
- 文件上傳
- 消息通知
- 消息通知
- Bootstrap消息
- izitoast
- SweetAlert
- 模態框
- 表單管理
- 異步請求
- 表單提交
- 表單驗證
- 擴展組件
- GET參數
- 剪貼板
- 表情選擇
- 圖表
- 拾色器
- 二維碼生成
- 光標控制
- 數據驗證
- md5
- 設備檢測
- Loading
- 預覽圖片
- 圖標庫
- COOKIE
- 百度地圖
- 城市選擇
- Vue.js
- jQuery
- axios
- 播放器
- 幻燈片
- 代碼高亮
- 阿里云OSS
- 驗證碼
- 頁面滾動
- lodash
- momentjs
- markdownIt
- 元素頁面固定
- 編輯器
- ueditor
- editor.md
- SimpleMDE
- simditor
- 自定義組件
- 1.0(舊版)
- 基礎知識
- 作者向軍
- 安裝配置
- 查看效果
- 元素樣式
- 日期時間
- 日期選擇
- 日期區間
- 時間選擇
- moment
- 上傳處理
- 圖片上傳
- 文件上傳
- 后臺處理
- 模態消息
- 模態
- notify
- bootstrap
- 表單管理
- 表單提交
- 表單驗證
- 表單樣式
- 擴展組件
- 自定義組件
- get參數
- 剪貼板
- 表情選擇
- 圖表
- 拾色器
- 二維碼生成
- 光標控制
- 數據驗證
- MD5
- loading
- 預覽圖片
- 圖標庫
- COOKIE
- 百度地圖
- 城市選擇
- Vuejs
- jQuery
- 播放器
- 幻燈片
- axios
- 代碼高亮
- 阿里云OSS
- 驗證碼
- 正則表達式
- 工具函數
- 編輯器
- 百度編輯器
- markdown
- simplemde-markdow