更新时间:2022-05-13 22:15:26
您不能从客户端调用EJS变量,必须将JSON输出到页面,然后再获取
You can't call the EJS variables from the clientside, you have to output the JSON to the page, and then fetch it
<script type="text/javascript">
var json_data = <%- JSON.stringify( holdings ); %>
// use the above variable in D3
</script>
<div class="portfolio">
<h2><%= holdings.ReportHeading1 %></h2>
<ul>
<li>Cash: <%= holdings.CashMV %></li>
<li>Fixed Income: <%= holdings.FixedMV %></li>
<li>Equity: <%= holdings.EquityMV %></li>
<li>Alternatives: <%= holdings.AltMV %></li>
</ul>
<div class="chart">
</div>
</div>