UEditor使用报错Cannot set property 'innerHTML' of undefined
set 报错 of 39 Cannot Property undefined
2023-09-27 14:23:20 时间
仿用UEditor的setContent的时候报错,报错代码如下Uncaught TypeError: Cannot set property ‘innerHTML’ of undefined。调试ueditor.config.js,ueditor.all.js 提示me.body is undefined。(我就纳了闷儿了!同样的使用那个行这个咋就不行,那个有body,view,这个咋就这么少!【我还查看了插件的内部函数,真是个good媛~】)错误的原因是没有等UEditor创建完成就使用UEditor的setContent函数了,可以通过如下两种代码解决 :
ueditor.addListener("ready", function () {
ueditor.setContent('str');
});ueditor.ready(function() {
ueditor.setContent('str');
});
ps:
var ue = UE.getEditor('containerId'); var a = "<%= info.C_Introdution || '' %>"; a = escape2Html(a); $("#introdution").html(a); function escape2Html(str) { if(str.indexOf(""")){ str = str.replace(/"/ig,"""); } var arrEntities={'"':'"','lt':'<','gt':'>','nbsp':' ','amp':'&','quot':'"'}; return str.replace(/&(lt|gt|nbsp|amp|quot);/ig,function(all,t){return arrEntities[t];}); } ue.ready(function() { ue.setContent(a); ue.addListener("contentchange", function () { $("#introdution").html(ue.getContent()); }) });
相关文章
- Can HTML checkboxes be set to readonly?
- AFNetworking 报错JSON text did not start with array or object and option to allow fragments not set…
- uniapp - props、 ref、$emit、$parent、$child、$on、$set
- MySQL 中 find_in_set() 函数的使用
- Java中集合Set的用法
- Redis操作Set工具类封装,Java Redis Set命令封装
- eclipse下提交job时报错mapred.JobClient: No job jar file set. User classes may not be found.
- watchpoint set variable
- 判断List、Map、Set是否为空及效率比较
- openharmony编译报错ubuntu20.04按照官方文档,hb set报错为OHOS ERROR] Invalid vendor path: /home/openharmony/vendor
- SET NOCOUNT ON
- sqlserver中set IDENTITY_INSERT on 和 off 的设置方法
- 【bzoj1018】[SHOI2008]堵塞的交通traffic 线段树区间合并+STL-set