UEditor显示Invalid or unexpected token
原文链接http://www.qqdeveloper.com/a/53.html
问题背景
数据修改操作,需要做一个数据内容回显,该内容中包含代码、图片、普通文本等等内容,反正就是各种内容。
当做数据回显时,用的是ueditor的setContent()函数。
错误情况
下面是错误信息,和错误信息的位置


开发代码
使用的是tp5,具体代码实现如下。这是html代码
<script id="container" name="content" type="text/plain">
{:htmlspecialchars_decode($artic_content['artic_content'])}
</script>
js使用setContent()渲染内容
var ue = UE.getEditor('container');
ue.ready(function () {
ue.setContent('{$content}');
});
使用上述方式,则显示上面的错误信息
解决方案
我这里就没用到js,也就是说没用ueditor的setContent()方法。直接在html中写入内容。在js中初始化一下编辑器,这里就不添加代码了。
使用了PHP的内置函数htmlspecialchars_decode()函数,将文本内容转实体。官方手册
<script id="container" name="content" type="text/plain">
{:htmlspecialchars_decode($artic_content['artic_content'])}
</script>
问题回顾
至于为什么用ueditor的setContent()出现如下错误,还未想明白。如果看到文章的你,发现怎么回事,请评论区留言。
额外收获
在thinkphp框架中,模板函数可以使用自定义函数也可以使用PHP内置函数,使用方法就是上面解决方案中使用的方式。
具体参考手册的文档底部有说明
UEditor显示Invalid or unexpected token的更多相关文章
- Invalid or unexpected token:数据格式错误
一个查询页面突然出现如下这个错误: Uncaught SyntaxError: Invalid or unexpected token, 翻译成中文是: 捕获的查询无效或意外的标记. 既然代码逻辑没问 ...
- Uncaught SyntaxError: Invalid or unexpected token
出现错误的地方:在Jquery中,调用有参数的方法,动态传递参数时报错 出现错误的原因: 动态传递参数的时候,参数中有换行符 错误的解决:参数传递之前,将换行符替换 var temp = model ...
- 【报错】invalid or unexpected token
结果发现是把英文的,写成了中文字符,系统没法识别.
- VM363:1 Uncaught SyntaxError: Invalid or unexpected token
此报错主要是因为json字符串转json对象时,json字符串中出现特殊字符(如:换行符)报错. json字符转json对象(如下写则报错) 更改后 参考地址: https://www.cnblogs ...
- jsp页面的html代码显示不出来,提示Uncaught SyntaxError: Unexpected token <
jsp页面的html代码显示不出来,提示Uncaught SyntaxError: Unexpected token < <input type="hidden" na ...
- 记一次debug记录:Uncaught SyntaxError: Unexpected token ILLEGAL
在使用FIS3搭建项目的时候,遇到了一些问题,这里记录下. 这里是发布搭建代码: // 代码发布时 fis.media('qa') .match('*.{js,css,png}', { useHash ...
- 使用cygwin出现syntax error near unexpected token'$'do\r
直接从csdn复制粘贴的.sh代码,放到cygwin下运行sh的时候出错syntax error near unexpected token'$'do\r 解决方法: 1.下载notepad++ 2. ...
- 写shell,运行出错:syntax error near unexpected token `$’do\r”
cygwin下面写shell,运行出错:syntax error near unexpected token `$’do\r” 写shell,运行出错:syntax error near unexpe ...
- linux shell-syntax error near unexpected token错误
在windows下用记事本编写linux shell脚本后,执行遇到syntax error near unexpected token错误 问题原理:网上找了好久,找到原因,原来是回行的问题,每个系 ...
随机推荐
- 修改虚拟机ip备份
修改虚拟机ip 因为别人写的很好,在此备份一下.
- mongodb数据库索引管理
1:ensureIndex() 方法 MongoDB使用 ensureIndex() 方法来创建索引. 语法 ensureIndex()方法基本语法格式如下所示: }) 语法中 Key 值为你要创建的 ...
- sql server——子查询
简述: 在查询语句中包含着有另外一条查询语句,被包含的查询语句称为子查询,包含着子查询的查询就称为父查询. 总之,子查询就是在查询语句里嵌套一条或者多条查询语句. 常用子查询分类: 一.独立子查询 特 ...
- 实现UILabel渐变色效果
实现UILabel渐变色效果 效果如下图: 源码: // // CombinationView.h // ChangeColorLabel // // Created by YouXianMing o ...
- Maven学习---使用maven进行项目构建
1. 使用maven进行项目构建 MyEclipse 自带maven 插件 Eclipse 需要单独安装maven插件 1.1. Maven 在企业中怎么用的 ? Maven : 项目构建工具 ,进行 ...
- sql with 写法
with h_asign_id as ( select asign_id from assign_h h left join assignment a on a.id = h.asign_id whe ...
- 全链路实践Spring Cloud 微服务架构
Spring Cloud 微服务架构全链路实践Spring Cloud 微服务架构全链路实践 阅读目录: 网关请求流程 Eureka 服务治理 Config 配置中心 Hystrix 监控 服务调用链 ...
- Makefile 实例
CROSS_COMPILE = HI_CFLAGS= -Wall -O2 -g -march=armv7-a -mcpu=cortex-a9 -mfloat-abi=softfp -mfpu=vfpv ...
- nfs 服务器
1.创建共享目录 #mkdir /home/hellolinux/nfs 2.创建或修改/etc/exports文件 #vi /etc/exports home/hellolinux/nfs 192. ...
- 迷宫问题——BFS
改进版 BFS #include <bits/stdc++.h> using namespace std; #define coordi(x,y) ( m*(x-1)+y ) const ...