Py学习  »  Jquery

扩展html python flask中无法识别jquery

Tommy • 5 年前 • 1666 次点击  

不知道这是怎么回事。似乎jquery没有从base.html文件“扩展”到外部文件。

我有:

#base.html

<!doctype html>
<html class="no-js" lang="en">

<head>
...
... # css imports
</head>

<body>

   # some fixed stuff

   {% block body %}

      # some stuff specific to base.html

   {% endblock %}

   # js imports at the end of the body

   <script src="static/js/jquery-3.1.0.min.js"></script>

    ... # various other js
</body>
</html>

然后我有另一个HTML文件:

#test.html

{% extends "base.html" %}

{% block body %}

    # some stuff

   <script type="text/javascript">

        $(document).ready( function () {
             alert("foo")
         } );

    </script>

{% endblock %}

现在,我没有任何警觉。但是,如果我使用普通的javascript,它会按预期工作。

我注意到,如果在test.html中再次导入jquery,jquery就可以正常工作。但那扩展的意义何在?

一定是我遗漏了什么。顺便说一下,这似乎只在jquery中发生,所有其他javascript库似乎都得到了很好的扩展。

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/43153
 
1666 次点击  
文章 [ 3 ]  |  最新文章 5 年前