今天碰到一个问题,页面报错: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;">';
}
}

最新文章

  1. 设计模式 &ldquo;续&rdquo;
  2. maven安装nexus私服
  3. JQuery源码解析(一)
  4. 【读书笔记】iOS网络-负载
  5. Oracle 存储过程学习
  6. MVC项目实践,在三层架构下实现SportsStore-02,DbSession层、BLL层
  7. 【leetcode❤python】Binary Watch
  8. 九度OJ1468
  9. sprintf函数减少字符串拼接错误
  10. hdu 1669(二分+多重匹配)
  11. mysql判断某个字符串是否包含另一个
  12. lua 与 php 通过AES数据加密进行通讯
  13. 真分布式SolrCloud+Zookeeper+tomcat搭建、索引Mysql数据库、IK中文分词器配置以及web项目中solr的应用(1)
  14. JSON 理解
  15. 附录:MySQL忘记root密码
  16. BigDecimal.valueOf
  17. ios 11 SDK 新特性 使用
  18. linux用户、文件权限相关命令
  19. Ubuntu64位下使用eclipse闪退的解决
  20. 判断计算机是否可以ping通

热门文章

  1. Spring bean 创建过程源码解析
  2. hdu 2829 斜率DP
  3. 异或值 xor
  4. 如何用js让表格的行也能拖动
  5. mvvm实现
  6. TCP面试题之四次挥手过程
  7. 消耗战(bzoj 2286)
  8. 高级全局API钩取 - IE连接控制
  9. 让Asp.net Web预启动
  10. JDK7集合框架源码阅读(四) LinkedHashMap