在网页中使用富文本编辑器editor+vue
2018-10-27 10:07
330 查看
先下载一个富文本编辑器(官网地址)
在vue中新建一个editor.vue
[code]<template> <div> <script id="editor" type="text/plain"></script> </div> </template> <script> export default { name: 'UE', data () { return { editor: null } }, props: { defaultMsg: { type: String }, config: { type: Object } }, mounted() { const _this = this; this.editor = UE.getEditor('editor', this.config); // 初始化UE this.editor.addListener("ready", function () { _this.editor.setContent(_this.defaultMsg); // 确保UE加载完成后,放入内容。 }); }, methods: { getUEContent() { // 获取内容方法 return this.editor.getContent() } }, destroyed() { this.editor.destroy(); } } </script> <style> </style>
把下载好的uditor压缩文件夹放在static中
改一下config里面的这一行(第一行)。
然后在需要用到的vue中使用它,具体如下:
[code]<template> <div class="components-container"> <div class="info"></div> <div class="editor-container"> <UE :defaultMsg=defaultMsg :config=config ref="ue"></UE> </div> </div> </template> <script> import UE from '../../editor.vue'; export default { components: {UE}, data () { return: { defaultMsg: '这里是UE测试', config: { initialFrameWidth: null, initialFrameHeight: 350 }, } } } </script> <style> .info{ border-radius: 10px; line-height: 20px; padding: 10px; margin: 10px; background-color: #ffffff; } </style>
然后效果就出来了。嗯,,如果感觉上面的功能太多了。可以看[文档]
还有图片的路径。反正我的图片出不来,所以正在改。。。
阅读更多相关文章推荐
- 关于EasyUI与富文本编辑器结合使用的问题(kindueditor与uueditor)
- 百度编辑器UEEDITOR使用简单介绍 UEditor表单提交和后台交互详解 最后更新对应的版本:1.2.5.1 教程描述: 富文本编辑器的使用开发中,表单提交有多种场景,编辑器初始化有新增文章和编辑
- javascript网页富文本编辑器:kindedit富文本编辑器插件的使用
- 使用百度editor 富文本编辑器上传图片
- asp.net留言板 利用富文本编辑器实现美化功能xheditor在asp.net网页的配置和使用
- vue中使用vue-quill-editor富文本编辑器,自定义toolbar修改工具栏options
- Vue-Quill-Editor富文本编辑器的使用教程
- vue-quill-editor富文本编辑器简单使用方法
- 在网页中添加富文本编辑器——UEditor的使用
- 在网页中使用TTS技术的例子
- laravel使用phantomJS实现网页全屏截图
- 如何解决IE8中eWebEditor编辑器按钮不能正常使用
- 一个极易使用的menu editor.
- 使用WebBrowser控件获取网页源码的方法
- java中使用WebView提取指定网页的HTML内容
- 使用Python中的urlparse、urllib抓取和解析网页(一)(转)
- 使用java开源工具httpClient及jsoup抓取解析网页数据
- Android登录客户端,验证码的获取,网页数据抓取与解析,HttpWatch基本使用
- Url Protocol-从网页中打开应用程序(exe)-使用小记