我在Django
和Angular 4
前端有一个web服务器,但我的问题是我不能在模板angular中使用Django标记。在
例如
我有这个索引.html像根目录/templates(django)
{% load static %}
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>TrackerFrontend</title>
<base href="{% static %}">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link
href="https://fonts.googleapis.com/icon?family=Material+Icons"
rel="stylesheet">
<!--<link
rel="stylesheet"
type="text/css"
href="http://fonts.googleapis.com/css?family=Fontin">
Not work
-->
</head>
<body>
<app-root>Loading...</app-root>
<script type="text/javascript" src="{% static 'inline.bundle.js' %}"></script>
<script type="text/javascript" src="{% static 'polyfills.bundle.js' %}"></script>
<script type="text/javascript" src="{% static 'styles.bundle.js' %}"></script>
<script type="text/javascript" src="{% static 'vendor.bundle.js' %}"></script>
<script type="text/javascript" src="{% static 'main.bundle.js' %}"></script>
</body>
</html>
如果我尝试从服务器调用媒体文件,我可以看到这一点
^{pr2}$但当我复制并粘贴相同的img标记时,在项目angular中执行npm run build
并再次运行我的服务器时,终端中会收到错误
Template parse errors:
Unexpected character "EOF" (Do you have an unescaped "{" in your template? Use "{{ '{' }}") to escape it.)
这个索引.html是一个真实的前端应用程序的副本,但是我添加了{% load static %}
和其他标记来调用bundle.js
文件。在
有没有可能在每个角分量内部复制这个调用{% load static %}
?在
同样的错误不需要执行npm run build
改变
<img src="{% get_media_prefix %}/images/2017-08-12-19-28-20st1folio1.png">
到<img src="{{ get_media_prefix }}/images/2017-08-12-19-28-20st1folio1.png">
相关问题 更多 >
编程相关推荐