在JS Render模板中使用AND(&&)运算符会抛出异常。但OR(||)运算符工作正常。
<svg width="100" height="100" style="margin-top:-50px">
{{if orderValue === 0 && orderValue1 === 1}}
<circle cx="30" cy="30" r="20" fill="orange"></circle>
{{else}}
<circle cx="30" cy="30" r="20" fill="red"></circle>
{{/if}}
</svg>
演示链接:https://jsplayground.syncfusion.com/zpv4v5f1
错误详细信息
请提供解决此问题的建议。
发布于 2018-01-23 18:30:49
您已经在<div>
元素中声明了您的模板。这不是个好主意!您应该使用脚本元素。
<script id="template" type="text/x-jsrender">...
参见http://www.jsviews.com/#compiletmpl。
模板标记不一定是有效的超文本标记语言,因此将其放入超文本标记语言<div>
或类似文档中可能会导致浏览器对其进行修改。在您的例子中,浏览器转义了& symbols:{{if orderValue === 0 && orderValue1 === 1}}
-,因此它不再是一个有效的模板。
此外,您正在使用的JsRender版本是第一个测试版。从那时起,已经有了许多修复和改进。使用最新的版本会更好,比如https://cdnjs.com/libraries/jsrender。(参见http://www.jsviews.com/#download)
https://stackoverflow.com/questions/48398981
复制相似问题