仿用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. scrapy项目1:爬取某培训机构老师信息(spider类)

    1.scrapy爬虫的流程,可简单该括为以下4步: 1).新建项目---->scrapy startproject 项目名称(例如:myspider) >>scrapy.cfg为项目 ...

  2. vue-cli 构建的 Vue 项目用 localhost 加 端口 能访问,但是切换到 ip 加 端口 就不能访问

    问题出在 webpack 的配置 在 config 文件夹下, 找到 index.js 目录, 找到如下代码 host: 'localhost', // can be overwritten by p ...

  3. [CSP-S模拟测试]:数对(线段树优化DP)

    题目传送门(内部题96) 输入格式 第一行一个整数$n$,接下来$n$行每行三个整数$a_i,b_i,w_i$. 输出格式 一行一个整数表示最大权值和. 样例 样例输入: 54 4 12 3 31 5 ...

  4. java-String与Integer的相互转化

    一.Integer转String //方法一:Integer类的静态方法toString() Integer a = 2; String str = Integer.toString(a)   //方 ...

  5. modern php笔记---2.1、特性(命名空间、特性、性状)

    modern php笔记---2.1.特性(命名空间.特性.性状) 一.总结 一句话总结: legend2是真的非常好用,资质起码提升5倍,也就是学习效率提升了起码5倍 1.命名空间实质? 从技术层面 ...

  6. sass scss less 的编译工具 koala

    使用 koala 时注意事项: 1.目录中一定不能出现中文,否则就会报错 2.文件中如果出现中文(!注释也算) 开头一定要加   @charset "utf-8"; 否则就会出现无 ...

  7. WINDOWS API 大全(二)

    9. API之设备场景函数 CombineRgn 将两个区域组合为一个新区域CombineTransform 驱动世界转换.它相当于依顺序进行两次转换CreateCompatibleDC 创建一个与特 ...

  8. (转)使用NMAP工具扫描端口

    原文:http://www.linuxde.net/2013/02/12354.html nmap 是一个用于网络探索或安全评测的工具.它支持 ping 扫描(判定哪些主机在运行),多端口扫描技术(判 ...

  9. Eureka服务注册与发现-提供消费服务模型

    1.工具及软件版本 JDK1.8 Spring Boot 1.4.3.RELEASE <parent> <groupId>org.springframework.boot< ...

  10. CSS样式div

    页面中,有很多样式标签:div标签,对标签定位的地方有: 1.<head>标签里加<style>标签,在<style>标签中添加样式.如: <style> ...