![](/img/trans.png)
[英]How to access template variables in the script section of my HTML file in Google Apps Script?
[英]Html how to inlcude script in my template?
我有一個問題問你。
我正在嘗試創建一個文件 js,其中包含我的 html 頁面中的所有圖表。 結構如下:
___base.html
___scripts.html
___conto_economico.html
___charts.html
在我的 base.html 中,我以下列方式包含了 scripts.html:
{% block javascript %}
{% include 'adminlte/lib/_scripts.html' %}
{% endblock %}
在我的 scripts.html 我已經包含了所有腳本,還有charts.js
文件
{% load static %}
{% block scripts %}
<script src="{% static 'admin-lte/plugins/jquery/jquery.min.js' %}"></script>
<script src="{% static 'admin-lte/plugins/jquery-ui/jquery-ui.min.js' %}"></script>
<script src="{% static 'admin-lte/plugins/chart.js/Chart.min.js' %}"></script>
<script src="{% static 'charts/charts.js' %}"></script>
{% endblock %}
最后,在 conto_economico.html 中,我擴展了我的基礎並以下列方式包含 scripts.html:
{% extends 'adminlte/base.html' %}
{% load static %}
{% block content %}
{% include 'adminlte/lib/_scripts.html' %}
.....
<canvas class=" w-100 " id="chart" height="180" ></canvas>
......
{% endblock content %}
但是我的“圖表”沒有上傳到我的頁面中。 錯誤在哪里?
編輯
我的設置 stati 文件如下:
STATIC_URL = '/static/'
STATIC_ROOT= [
os.path.join(BASE_DIR, 'static'),
]
在我的我有兩個 static 文件夾:
my_project/static
中的第一個v_env\Lib\site-packages\adminlte3\static
中的第二個是我的 base.html 文件和腳本文件的位置。可能是這個問題嗎?
您的 base.html 和 _scripts.html 位於同一文件夾中。 做就是了:
{% include '_scripts.html' %}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.