我正在追踪swampdragon tutorial。
我已经完成它,复制并粘贴了所有内容,但是当我在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>
关于javascript - swampdragon如何导入js文件?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31361857/