mba学费贷款,计秋君,专业功放电路图
最近在做后台管理系统的时候遇到要使用富文本编辑器。最后选择了ueditor,我的项目使用 vue+vuex+vue-router+webpack+elementui的方案完成框架的搭建,
1、下载ueditor官网最新的jsp版本的包,下载完成解压之后得到一个utf8-jsp的文件夹,里面包含的内容如下:
2、将这个文件夹改名为ueditor,并且移入自己项目中的static文件夹下,修改ueditor.config.js文件夹中的内容,如下图:
3、编写子组件
<template> <div :id="id" type="text/plain"></div> </template> <script> import '../../../static/ueditor/ueditor.config.js' import '../../../static/ueditor/ueditor.all.min.js' import '../../../static/ueditor/lang/zh-cn/zh-cn.js' import '../../../static/ueditor/ueditor.parse.min.js' export default { name: 'ue', data() { return { editor: null } }, props: { defaultmsg: { type: string, default: '请输入内容' }, config: { type: object }, id: { type: string, default: `ue${math.random(0, 100)}` } }, mounted() { this.$nexttick(() => { this.editor = ue.geteditor(this.id, this.config); // 初始化ue this.editor.addlistener("ready", () => { this.editor.execcommand('inserthtml', this.defaultmsg); this.editor.focus() // 确保ue加载完成后,放入内容。 }) }) }, methods: { getuecontent() { // 获取内容方法 return this.editor.getcontent() }, clearcontent() { // 清空编辑器内容 return this.editor.execcommand('cleardoc'); }, }, beforedestroy() { // 组件销毁的时候,要销毁 ueditor 实例 if (this.editor !== null && this.editor.destroy) { this.editor.destroy(); } } } </script> <style scoped></style>
4、在父组件中使用
<ue :config="configeditor" :id="ue1" ref="ue" :defaultmsg="val"></ue>
5、弄好之后,上传图片会提示后端配置项http错误,文件上传会提示上传错误。这里提别申明一点,ueditor在前端配置好后,需要与后端部分配合进行,然后将配置ueditor.config.js 里的serverurl的前缀改陈你自己的后端访问的请求路径地址
serverurl: "统一请求地址"
总结
以上所述是小编给大家介绍的vue中使用ueditor富文本编辑器,希望对大家有所帮助
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
详解element上传组件before-remove钩子问题解决
vue.js中使用微信扫一扫解决invalid signature问题(完美解决)
网友评论