首页 文章

我如何将.js传递给Jinja? [重复]

提问于
浏览
-1

这个问题在这里已有答案:

虽然我理解使用url_for在 static 中搜索register.js,但我的问题更基本 . 出于调试的目的, register.js 存在于 templates 中,也就是register.html和index.html所在的文件夹,但它似乎仍然不起作用 .

我想了解我应该如何通过jinja将.html文件中的.js文件连接起来 . 我存在于layout.html中,并以我尝试过的方式传递它 . 假设我有三个文件,layout.html,register.html和register.js .

我的layout.html目前看起来像这样
enter image description here

而我的register.html看起来像这样:
enter image description here

将.js文件连接到的正确语法是什么?

1 回答

  • 0

    在register.html中执行此操作

    {% block javascript %}
        {{ super() }} <-- This will invoke the parent code block 
    
        // Add js code here at register.html level
    {% endblock %}
    

相关问题