Uncaught SyntaxError: Invalid Unicode escape sequence异常处理
2024-09-04 10:57:40
今天碰到一个问题,页面报错:Uncaught SyntaxError: Invalid Unicode escape sequence
,{index:'operate',name:'operate',label:'<s:text name="com.vrv.cems.ptp.installSoft.operate"></s:text>',width:getPerWidth(0.1),
formatter:function(value,rec,index){
return '<img onclick="uninst(this,\''+index.uninstallMode+'\',\''+index+'\')" title="<s:text name="cems.unInstall"></s:text>" src="${basePath}/images/ptp/delete.png" width="16px" height="16px" style="cursor:pointer;">';
//return '<img onclick="uninst(this,\''+index.uninstallMode.replace(/\\/g,"/")+'\',\''+index+'\')" title="<s:text name="cems.unInstall"></s:text>" src="${basePath}/images/ptp/delete.png" width="16px" height="16px" style="cursor:pointer;">';
}
}
index.uninstallMode是一个软件的路径,
点击按钮,有时候就会出现所报错误,但是奇怪的是有的会报,有的不会报错
原因估计就是反斜杠在js里面是转义符导致的,如下:
正常的话应该如此:
所以考虑到的解决方案就是将一个反斜杠换成两个反斜杠,(这样后台返回json串时就要加4条反斜杠),如下果然正常执行:
当然换成正斜杠也可以。
所以将代码改为下面:
,{index:'operate',name:'operate',label:'<s:text name="com.vrv.cems.ptp.installSoft.operate"></s:text>',width:getPerWidth(0.1),
formatter:function(value,rec,index){
//return '<img onclick="uninst(this,\''+index.uninstallMode+'\',\''+index+'\')" title="<s:text name="cems.unInstall"></s:text>" src="${basePath}/images/ptp/delete.png" width="16px" height="16px" style="cursor:pointer;">';
return '<img onclick="uninst(this,\''+index.uninstallMode.replace(/\\/g,"/")+'\',\''+index+'\')" title="<s:text name="cems.unInstall"></s:text>" src="${basePath}/images/ptp/delete.png" width="16px" height="16px" style="cursor:pointer;">';
}
}
最新文章
- 设计模式 &ldquo;续&rdquo;
- maven安装nexus私服
- JQuery源码解析(一)
- 【读书笔记】iOS网络-负载
- Oracle 存储过程学习
- MVC项目实践,在三层架构下实现SportsStore-02,DbSession层、BLL层
- 【leetcode❤python】Binary Watch
- 九度OJ1468
- sprintf函数减少字符串拼接错误
- hdu 1669(二分+多重匹配)
- mysql判断某个字符串是否包含另一个
- lua 与 php 通过AES数据加密进行通讯
- 真分布式SolrCloud+Zookeeper+tomcat搭建、索引Mysql数据库、IK中文分词器配置以及web项目中solr的应用(1)
- JSON 理解
- 附录:MySQL忘记root密码
- BigDecimal.valueOf
- ios 11 SDK 新特性 使用
- linux用户、文件权限相关命令
- Ubuntu64位下使用eclipse闪退的解决
- 判断计算机是否可以ping通