Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/464.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Django静态URL在java脚本代码中的使用不起作用_Javascript_Python_Django_Hyperlink - Fatal编程技术网

Javascript Django静态URL在java脚本代码中的使用不起作用

Javascript Django静态URL在java脚本代码中的使用不起作用,javascript,python,django,hyperlink,Javascript,Python,Django,Hyperlink,我的问题是在java脚本代码中使用DjangoSTATIC\uURL。我的代码在我的开发环境中工作,但当我将其上传到pythonanywhere.com时,它就不工作了。我检查了我的代码相对路径,它正在工作,但使用静态URL它不工作我的代码如下所示: document.write(" <source data-src='{{STATIC_URL}}{{filename}}' type='video/mp4' >"); document.write(“”); 您应该使用如下内容 在

我的问题是在java脚本代码中使用Django
STATIC\uURL
。我的代码在我的开发环境中工作,但当我将其上传到pythonanywhere.com时,它就不工作了。我检查了我的代码相对路径,它正在工作,但使用静态URL它不工作我的代码如下所示:

document.write("  <source data-src='{{STATIC_URL}}{{filename}}' type='video/mp4' >");
document.write(“”);

您应该使用如下内容 在模板中导入静态文件:

{% load staticfiles %}
然后使用“static”访问静态目录:

<img src="{% static "my_app/myexample.jpg" %}" alt="My image"/>

这将指向文件系统和子目录“my_app”上的静态目录

所以你会:

document.write("  <source data-src='{% static "filename" %}' type='video/mp4' >");
document.write(“”);

签出。

您应该使用以下内容 在模板中导入静态文件:

{% load staticfiles %}
然后使用“static”访问静态目录:

<img src="{% static "my_app/myexample.jpg" %}" alt="My image"/>

这将指向文件系统和子目录“my_app”上的静态目录

所以你会:

document.write("  <source data-src='{% static "filename" %}' type='video/mp4' >");
document.write(“”);

签出。

您应该使用以下内容 在模板中导入静态文件:

{% load staticfiles %}
然后使用“static”访问静态目录:

<img src="{% static "my_app/myexample.jpg" %}" alt="My image"/>

这将指向文件系统和子目录“my_app”上的静态目录

所以你会:

document.write("  <source data-src='{% static "filename" %}' type='video/mp4' >");
document.write(“”);

签出。

您应该使用以下内容 在模板中导入静态文件:

{% load staticfiles %}
然后使用“static”访问静态目录:

<img src="{% static "my_app/myexample.jpg" %}" alt="My image"/>

这将指向文件系统和子目录“my_app”上的静态目录

所以你会:

document.write("  <source data-src='{% static "filename" %}' type='video/mp4' >");
document.write(“”);

检查。

是在.js文件中还是在html文件的标记中写入javascript代码?是在.js文件的标记中写入java脚本代码,还是在html文件的标记中写入javascript代码?是在.js文件的标记中写入java脚本代码,还是在html文件的标记中写入javascript代码文件?它的java脚本代码是用tags编写的,而不是用.js文件编写的,还是在html文件的标记中编写的javascript代码?它的java脚本代码是用标记编写的