1
我想將一個JSON對象或字符串存儲在Underscore模板中。如何將JSON數據存儲在Underscore模板中?
<script id="report_field_template" type="text/template">
<div data-options="<%= options %>" role="<%- role %>" title="<%- title %>" class="ui-widget-content ui-corner-all report_field">
<p><%- field_text %></p>
</div>
</script>
如果我將「options」作爲JSON字符串或JSON對象傳遞,上述方法將不起作用。有任何想法嗎?
我會確保你的選項中沒有任何雙引號。您可能還需要使用<% - 來轉義選項。 – bottens