【发布时间】:2017-03-29 21:14:38
【问题描述】:
我的 grails 视图中有一个参数,我将其传递给 javascript 代码
<g:if test="${replacedString}">
${replacedString}
<g:set var="replacedString" value="${replacedString}"/>
</g:if>
<script>
var mydata = decodeURIComponent(${replacedString});
console.log(mydata);
</script>
replacedString 值作为编码字符串传递,即:" 显示为 &quot;。
因此,我有方法
decodeURIComponent
这是我要解码的字符串:
[{"description":"test1 ","filenameAndPath":"test1.pdf"},{"description":"test file","filenameAndPath":"test copy.pdf"},{"description":"","filenameAndPath":""},{"description":"","filenameAndPath":""}]
这段代码不断抛出错误Syntax error: Unexpected token &。
我错过了什么明显的东西吗?
【问题讨论】:
标签: javascript html grails