我有一个图表页面,当我打开我的基页时,我想将它包含在我的基页中,它显示我Variable "chart" does not exist
你可以看到我的图表页面:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"type="text/javascript"></script>
<script src="//code.highcharts.com/4.1.8/highcharts.js"></script>
<script src="//code.highcharts.com/4.1.8/modules/exporting.js"></script>
<script type="text/javascript">{{ chart(chart) }}</script>
<div id="barchart" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
在我的基页我写这个
{% include 'companyevents/charts.html.twig'%}
答案 0 :(得分:-1)
{# template.html will have access to the variables from the current context and the additional ones provided #}
{% include 'template.html' with {'foo': 'bar'} %}
Bar应存在于当前上下文中或使用'with'
传递https://twig.sensiolabs.org/doc/2.x/tags/include.html
您在基本模板中设置了'图表'吗?