Skip to content

Commit 87d20e6

Browse files
committed
添加UE编辑器示例
1 parent 666339c commit 87d20e6

File tree

12 files changed

+98
-15
lines changed

12 files changed

+98
-15
lines changed

build/webpack.base.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module.exports = {
2626
'vue$': 'vue/dist/vue.common.js',
2727
'src': path.resolve(__dirname, '../src'),
2828
'assets': path.resolve(__dirname, '../src/assets'),
29-
'components': path.resolve(__dirname, '../src/components')
29+
'components': path.resolve(__dirname, '../src/views')
3030
}
3131
},
3232
resolveLoader: {

src/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
</el-row>
2121
</template>
2222
<script>
23-
import header from './components/header/header.vue';
23+
import header from './views/header/header.vue';
2424
const ERR_OK = "000";
2525
export default {
2626
data () {

src/components/other/other.vue

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/components/ue/ue.vue

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<template>
2+
<div>
3+
<script id="editor" type="text/plain"></script>
4+
</div>
5+
</template>
6+
<script>
7+
export default {
8+
name: 'UE',
9+
data () {
10+
return {
11+
editor: null
12+
}
13+
},
14+
props: {
15+
defaultMsg: {
16+
type: String
17+
},
18+
config: {
19+
type: Object
20+
}
21+
},
22+
mounted() {
23+
const _this = this;
24+
this.editor = UE.getEditor('editor', this.config);
25+
this.editor.addListener("ready", function () {
26+
_this.editor.setContent(_this.defaultMsg);
27+
});
28+
},
29+
methods: {
30+
getUEContent() {
31+
return this.editor.getContent()
32+
}
33+
},
34+
destroyed() {
35+
this.editor.destroy();
36+
}
37+
}
38+
</script>

src/main.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,18 @@ import axios from 'axios';
66
import ElementUI from 'element-ui';
77
import 'element-ui/lib/theme-default/index.css';
88
import App from './App';
9-
import Index from './components/index/index';
10-
import Table from './components/table/table';
11-
import Form from './components/form/form';
12-
import other from './components/other/other';
9+
import Index from './views/index/index';
10+
import Table from './views/table/table';
11+
import Form from './views/form/form';
12+
import ue from './views/editor/editor';
1313
import 'font-awesome/css/font-awesome.min.css';
1414
import Mock from './mock/mock';
15+
16+
import '../static/UE/ueditor.config.js'
17+
import '../static/UE/ueditor.all.min.js'
18+
import '../static/UE/lang/zh-cn/zh-cn.js'
19+
import '../static/UE/ueditor.parse.min.js'
20+
1521
Mock.mockData();
1622
Vue.use(VueRouter);// 安装路由功能
1723
/* eslint-disable no-new */
@@ -45,7 +51,7 @@ let routes = [
4551
{path: '/index', component: Index, name: 'index', class: 'fa-line-chart'},
4652
{path: '/table', component: Table, name: 'table', class: 'fa-table'},
4753
{path: '/form', component: Form, name: 'form', class: 'fa-newspaper-o'},
48-
{path: '/other', component: other, name: 'other', class: 'fa-plug'}
54+
{path: '/editor', component: ue, name: 'editor', class: 'fa-plug'}
4955
]
5056
}
5157
];

src/views/editor/editor.vue

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<template>
2+
<div class="components-container">
3+
<div class="info">UE编辑器示例<br>需要使用编辑器时,调用UE公共组件即可。可设置填充内容defaultMsg,配置信息config(宽度和高度等),可调用组件中获取内容的方法。</div>
4+
<button @click="getUEContent()">获取内容</button>
5+
<div class="editor-container">
6+
<UE :defaultMsg=defaultMsg :config=config ref="ue"></UE>
7+
</div>
8+
</div>
9+
</template>
10+
<style>
11+
.info{
12+
border-radius: 10px;
13+
line-height: 20px;
14+
padding: 10px;
15+
margin: 10px;
16+
background-color: #ffffff;
17+
}
18+
</style>
19+
<script>
20+
import UE from '../../components/ue/ue.vue';
21+
export default {
22+
components: {UE},
23+
data() {
24+
return {
25+
defaultMsg: '这里是UE测试',
26+
config: {
27+
initialFrameWidth: null,
28+
initialFrameHeight: 350
29+
}
30+
}
31+
},
32+
methods: {
33+
getUEContent() {
34+
let content = this.$refs.ue.getUEContent();
35+
this.$notify({
36+
title: '获取成功,可在控制台查看!',
37+
message: content,
38+
type: 'success'
39+
});
40+
console.log(content)
41+
}
42+
}
43+
};
44+
</script>
45+
46+
47+
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)