1、报错“请求后台配置项http错误,上传功能将不能正常使用!”,如图所示:
解析:UEditor 提供了四种后台语言 php,asp,asp.net,jsp ,你可以查看下页面引用的ueditor.config.js文件内的serverUrl 参数,如果是:serverUrl: URL + "jsp/controller.php" 则是用的jsp,那你页面所在服务器必需是配置了对应的java服务器环境(如果是本机测试,则你本机必需装了java服务器环境),否则请改为对应的后台语言版本的ueditor!
2、编辑器实例化的时候可以传入什么配置参数来实现自定义?
解析:这就涉及到官方的前端配置项说明 ,ueditor.config.js文件里面的所有配置项在编辑器实例化时都可自定义!
3、怎么限制UEditor 上传图片的格式以及图片文件大小?
解析:这就涉及到官方的后端配置项说明, UEditor 1.4.2+ 起,把前后端相关的配置项都放到后端文件 php/config.json 设置,你可以测试你的网站下的路径 ueditor/php/controller.php?action=config 是否正常返回了json格式的后端配置内容,格式大致如下。如果这个请求出错,出现400、500等错误,编辑器上传相关的功能将不能正常使用。
config.json文件下的imageAllowFiles、imageMaxSize分别对应是是修改上传图片的格式、图片文件大小(默认是2048000B,即2M)
4、ueditor 上传图片显示:上传的文件不存在?
解析:发现是php配置限制了上传文件大小。。。。php.ini 里边 post_max_size 、 upload_max_filesize 这两个参数改一下就好了。
5、ueditor中怎么去掉自动保存提示?
解析:设置ueditor实例参数enableAutoSave: false失效,另改自动保存间隔时间, 单位ms ,saveInterval 设成足够长时间以达到屏蔽自动保存提示效果(ueditor1.5及以上版本已处理此Bug)
6、ueditor点击上传图片按钮明显延时弹出文件选择框?
解析:
上传单张图片按钮修改:修改ueditor.all.js(或ueditor.all.min.js)将accept的值从image/*改成一般常见的图片格式,如:image/jpeg,image/jpg,image/png
上传多张图片按钮修改:修改dialogs/image/image.js文件,将mimeTypes的值从image/*改成一般常见的图片格式,如:image/jpeg,image/jpg,image/png
注意:上述image/*修改,并不影响前面提到的后端配置项上传图片的格式的限制效果
7、ueditor怎么加入placeholder默认文字提示?
实例化ueditor 标签中加入你要显示的placeholder文字即可,代码如下所示:
<script id="editor" class="editor" type="text/plain"><p style="color:#999;">请输入主题内容</p></script>
或者
加入ueditor实例参数initialContent:'placeholder相应文字'
8、上面加入的placeholder,怎么在ueditor获得焦点时清除placeholder文字,失去焦点时若内容为空则再次显示placeholder文字?
单独设置ueditor实例参数autoClearinitialContent:true,输入内容再清空后无法恢复placeholder文字, 可加入下面代码实现:
editor.ready(function() {
// 控制placeholder文字显示、隐藏
this.addListener("focus", function(type, event) {
if(this.getContent().indexOf(bd_holder)!=-1){
this.setContent("");
}
})
this.addListener("blur", function(type, event) {
if(!this.hasContents()){
this.setContent(bd_holder);
}
})
});
9、ueditor实例界面底部不显示元素路径、当前输入文字统计信息?
ueditor实例加入参数
elementPathEnabled: false,
wordCount: false
10、怎么限制输入文字字数?
wordCount:{Boolean} [默认值:true] //是否开启字数统计;
maximumWords {Number} [默认值:10000] //允许的最大字符数;
wordCountMsg {String} [默认值:] //当前已输入 {#count} 个字符,您还可以输入{#leave} 个字符,字数统计提示,{#count}代表当前字数,{#leave}代表还可以输入多少字符数,留空支持多语言自动切换,否则按此配置显示
完整实例代码,如下:
<div class="editor-box">
<script id="editor" class="editor" type="text/plain"><p style="color:#999;">请输入主题内容</p></script>
</div>
<script src="/js/ueditor1_4_3_php/ueditor.config.js"></script>
<script src="/js/ueditor1_4_3_php/ueditor.all.js"></script>
<script>
/*百度编辑器实例化*/
var bd_holder=$("#editor").html().trim();
var editor = UE.getEditor('editor', {
initialFrameHeight: 290, //初始化高度
autoHeightEnabled: false,
enableAutoSave: false,
saveInterval: 1800000,
initialStyle: "body{margin:8px 17px;font-size:14px;}p{margin:0;line-height:20px;}",
toolbars: [
['cleardoc', 'bold', 'forecolor', 'italic', 'underline', 'fullscreen', 'superscript', 'subscript', 'spechars', 'insertimage', ]
],
elementPathEnabled: false,
wordCount: false,
autoClearinitialContent:true
});
editor.ready(function() {
// 控制placeholder文字显示、隐藏
this.addListener("focus", function(type, event) {
if(this.getContent().indexOf(bd_holder)!=-1){
this.setContent("");
}
})
this.addListener("blur", function(type, event) {
if(!this.hasContents()){
this.setContent(bd_holder);
}
})
});
</script>
更多常见问题解决方法,持续更新中...
0条评论( 网友:0 条,站长:0 条 ) 网友评论{有您的评论更精彩....}