我遵循swampdragon教程。我已经完成了,复制和粘贴的一切,但当我在http://localhost:8000/,我得到了这个错误在javascript控制台。
GET http://localhost:8000/swampdragon/js/dist/datamapper.js
GET http://localhost:8000/swampdragon/js/angular/services.js
GET http://localhost:8000/controllers.js
GET http://localhost:8000/app.js
angular.js:36Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.2.21/$injector/modulerr?p0=TodoApp&p1=Error%3…gleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.2.21%2Fangular.min.js%3A18%3A277)
这是我的设置:
STATIC_URL = '/static/'
# SwampDragon settings
SWAMP_DRAGON_CONNECTION = ('swampdragon.connections.sockjs_connection.DjangoSubscriberConnection', '/data')
TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
DRAGON_URL = 'http://localhost:9999/'
这里是index。html:
{% load static swampdragon_tags %}
html code
...
...
<!-- AngularJS -->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.21/angular.min.js"></script>
{% swampdragon_settings %}
<script type="text/javascript" src="{% static 'swampdragon/js/dist/swampdragon.min.js' %}"></script>
<script type="text/javascript" src="{{ STATIC_URL }}swampdragon/js/dist/datamapper.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}swampdragon/js/angular/services.js"></script>
<!-- To-do app -->
<script type="text/javascript" src="{{ STATIC_URL }}app.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}controllers.js"></script>
所以我在github上得到了答案,这里是解决方案。是STATIC_URL。
{% swampdragon_settings %}
<script type="text/javascript" src="{% static 'swampdragon/js/dist/swampdragon.min.js' %}"></script>
<script type="text/javascript" src="{{ static }}swampdragon/js/dist/datamapper.js"></script>
<script type="text/javascript" src="{{ static }}swampdragon/js/angular/services.js"></script>
<!-- To-do app -->
<script type="text/javascript" src="{{ static }}app.js"></script>
<script type="text/javascript" src="{{ static }}controllers.js"></script>