Uncaught SyntaxError: Invalid Unicode escape sequence异常处理

  今天碰到一个问题,页面报错:Uncaught SyntaxError: Invalid Unicode escape sequencejson

,{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是一个软件的路径,this

  点击按钮,有时候就会出现所报错误,可是奇怪的是有的会报,有的不会报错spa

  缘由估计就是反斜杠在js里面是转义符致使的,以下:3d

  正常的话应该如此:code

  因此考虑到的解决方案就是将一个反斜杠换成两个反斜杠,(这样后台返回json串时就要加4条反斜杠),以下果真正常执行:orm

  固然换成正斜杠也能够。blog

  因此将代码改成下面:get

,{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;">'; } }
相关文章
相关标签/搜索