仿用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函数了,可以通过如下两种代码解决 :

  1. ueditor.addListener("ready", function () { 
    ueditor.setContent('str'); 
    });
  2. 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());
})
});

  

 

js转换html转义字符

UEditor使用报错Cannot set property 'innerHTML' of undefined的更多相关文章

  1. adb驱动安装和使用报错笔记

    adb驱动安装 adb驱动下载地址:https://adb.clockworkmod.com/ 安装时候选择一个容易记住的路径,这个很重要,因为adb驱动没有自动配置环境变量,所以实验时候将adb安装 ...

  2. animate is not a function(zepto 使用报错)[转]

    animate is not a function(zepto 使用报错) 1.为什么使用zepto写animate报错? 因为zepto默认构建包含: Core, Ajax, Event, Form ...

  3. Windows下Git使用报错:warning:LF will be replaced by CRLF in ××××.××

    Windows下Git使用报错: warning:LF will be replaced by CRLF in ××××.××(文件名) The file will have its original ...

  4. yum源使用报错

    CentOS系统yum源使用报错:Error: Cannot retrieve repository metadata (repomd.xml) for repository: rpmforge. 服 ...

  5. 2019-9-9:渗透测试,docker下载dvwa,使用报错型sql注入dvwa

    docker下载dvwa镜像,报错型注入dvwa,low级 一,安装并配置docker 1,更新源,apt-get update && apt-get upgrade &&am ...

  6. .net core中Grpc使用报错:The remote certificate is invalid according to the validation procedure.

    因为Grpc采用HTTP/2作为通信协议,默认采用LTS/SSL加密方式传输,比如使用.net core启动一个服务端(被调用方)时: public static IHostBuilder Creat ...

  7. VirtualBox使用报错

    VirtualBox使用报错 1.启动报错:Failed to instantiate CLSID_VirtualBox... 报错内容: Failed to instantiate CLSID_Vi ...

  8. 小程序 for循环 报错 Cannot read property 'total' of undefined

    for循环一直报错  Cannot read property 'total' of undefined,但total在起初是有定义的,后来找到了问题,是i<=的问题,改为<不报错了. i ...

  9. datatables 多一列报错Cannot read property 'sWidth' of undefined(…)/少一列报错Cannot read property 'style' of undefined(…)

    datatables 多一列报错Cannot read property 'sWidth' of undefined(…)/少一列报错Cannot read property 'style' of u ...

随机推荐

  1. [CF1101F]Trucks and Cities:分治优化决策单调性

    分析 好像是有一个叫这个名字的算法,链接. 令\(f[i][j][k]\)表示一辆每公里耗油量为\(1\)的货车从\(i\)到\(j\)中途加\(k\)次油最小的油箱容量.枚举所有的起点和中途加油的次 ...

  2. final修饰的类,其属性和方法默认是被final修饰的吗?

    在论坛上,看到一个问题,当然,各位聪明的客官想必已经知道问题是什么了,嘿嘿,没错就是文章的标题:final修饰的类,其属性和方法默认是被final修饰的吗? 老实说,刚开始看到这个问题的时候,有点懵. ...

  3. Docker push image to Docker hub

    1. Before push image to Docker Hub, register an account in https://hub.docker.com/ 2.Input "doc ...

  4. ASP.NET中调用百度地图API

    1.打开链接http://developer.baidu.com/map/jshome.htm这里有很多DEMO,或者你直接百度搜索“百度地图API”,第一个就是.进入后有很多方向供你选择,由于现在开 ...

  5. Ping链路测试

    https://help.aliyun.com/knowledge_detail/40573.html?spm=5176.2020520165.121.d519.4b4f7029sHzfmi#TRAC ...

  6. 【ASK】设置网卡启动遇到的事!

    上次动笔是16年的事情了,一晃3年过去了.算了,不感慨了.直奔主题吧. 1.今天朋友要把一批win10的机器设置成网卡启动. 2.网卡是intel集成的. 3.按照主板说明已经设置成功. 4.通过wi ...

  7. HTML和JS完成页面点击四个角弹出管理页面

    实现方法1: HTML代码: <div class="top-left-corner"></div> <div class="top-rig ...

  8. python - MySQLdb 事务处理及批量执行executemany

    MySQL数据库有一个自动提交事务的概念,autocommit.含义是,如果开启autocommit, 则每一个语句执行后会自动提交.即一个语句视为一个事务. 在python使用的MySQLdb中,默 ...

  9. 阶段3 1.Mybatis_09.Mybatis的多表操作_7 mybatis多对多准备角色表的实体类和映射配置

    创建Role表和user_role表 DROP TABLE IF EXISTS `role`; CREATE TABLE `role` ( `ID` int(11) NOT NULL COMMENT ...

  10. c# 跨应用程序域通讯

    public class MyTask { public class MyEventArgs : EventArgs { public object EventData { get; private ...