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错误 问题原理:网上找了好久,找到原因,原来是回行的问题,每个系 ...
随机推荐
- tpcc-mysql安装测试与使用生成对比图
1:下载tpcc-mysql的压缩包,从下面的网站进行下载 https://github.com/Percona-Lab/tpcc-mysql 也可直接从叶总博客直接下载: http://imysql ...
- sql server 获取表结构和记录数
表结构 then d.name else null end) 表名, a.colorder 字段序号,a.name 字段名, ( then '√'else '' end) 标识, (case when ...
- js 浅拷贝有大用
如题 像浅拷贝.深拷贝这类的知识点我们应该都明白是怎么回事,大部分都是在面试的时候会被问到.大多让你实现一个深拷贝.现实中我们都用比较暴力直接的手段 JSON stringify. 一句话就搞定,管他 ...
- Linux 服务器性能问题排查思路
一个基于 Linux 操作系统的服务器运行的同时,也会表征出各种各样参数信息.通常来说运维人员.系统管理员会对这些数据会极为敏感,但是这些参数对于开发者来说也十分重要,尤其当你的程序非正常工作的时候, ...
- DESCRIBE:When you mouse click right-side is open an application and click left-side is attribution.
DESCRIBE:When you mouse click right-side is open an application and click left-side is attribution. ...
- mysql/MariaDB 搭建后创建密码及开启远程
创建密码: mysqladmin -u root -p password 123 或 MariaDB [(none)]> use mysql MariaDB [mysql]> update ...
- asp.net c# 断点续传 下载 Accept-Ranges
转自:http://www.cnblogs.com/90nice/p/3489287.html 1.因为要下载大文件 需要断点续传,使用多线程 分段下载 效率比较高,节省资源. 发点牢骚:下载可以用多 ...
- UVa 1151 - Buy or Build(最小生成树)
链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- BZOJ2141:排队(分块,树状数组)
Description 排排坐,吃果果,生果甜嗦嗦,大家笑呵呵.你一个,我一个,大的分给你,小的留给我,吃完果果唱支歌,大家 乐和和.红星幼儿园的小朋友们排起了长长地队伍,准备吃果果.不过因为小朋友们 ...
- git branch 相关操作总结 新建分支 删除分支 切换分支 查看分支
查看分支 (1) 查看本地分支 git branch 列出本地已经存在的分支,并且在当前分支的前面加*号标记,例如:localhost:website admin$ git branch* bran ...