引入js

  • 建立static文件夹: 
    django 1.10以上版本,引入js 
    注意上图里面static文件夹的路径,再在里面添加js文件夹,js文件夹里面就可以放我们需要的js文件了。
  • 配置相关文件 
    接下来,想要使用这些js我们还需要进行一些配置: 
    settings.py
1 STATIC_URL = '/static/'
2 
3 STATICFILES_DIRS = (
4     os.path.join(BASE_DIR, 'static'),
5 )

templates/hello.html

{% load staticfiles %}#这句添加在html文件的最上面

<script src="{% static "js/jquery-3.1.1.min.js" %}" type="text/javascript"></script>

#注意看这里面的script标签和我们之前的script标签之间的不同

 

相关文章:

  • 2022-12-23
  • 2021-09-28
  • 2021-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-18
猜你喜欢
  • 2021-05-22
  • 2021-11-07
  • 2022-12-23
  • 2021-07-03
  • 2021-04-13
  • 2022-02-10
  • 2022-12-23
相关资源
相似解决方案