Templates 使用backbone.js';text.js插件无法访问模板

Templates 使用backbone.js';text.js插件无法访问模板,templates,backbone.js,requirejs,Templates,Backbone.js,Requirejs,我得到错误get localhost:8080/scripts/templates/home/homeTemplate.html 404(未找到) 不知道为什么会这样。基于本教程,我觉得文件放在了正确的位置 github存储库就在这里 我像这样引用模板 “文本!templates/home/homemplate.html' 从app/templates/home…修改脚本/main.js,如下所示 require.config({ paths: { jquery: 'libs/jqu

我得到错误get localhost:8080/scripts/templates/home/homeTemplate.html 404(未找到)

不知道为什么会这样。基于本教程,我觉得文件放在了正确的位置

github存储库就在这里

我像这样引用模板 “文本!templates/home/homemplate.html'
从app/templates/home…

修改
脚本/main.js
,如下所示

require.config({
  paths: {
    jquery: 'libs/jquery',
    underscore: 'libs/underscore',
    backbone: 'libs/backbone',
    templates: '../templates'  // added
  }
});
require(['app'], function(App) {
  App.initialize();
});
通过如上所述设置
模板
, 如果模块ID以“模板”开头, requirejs从
模板
目录加载模块

如果没有上述
模板
设置,requirejs将从包含
main.js
源代码的
scripts
目录加载任何模块ID。因此,
文本!templates/home/homemplate.html
被解释为错误的URL
scripts/templates/home/home/homemplate.html

如果不想修改
main.js
脚本, 您可以通过以下方式指定
homemplate.html
的正确位置: 替换
”文本!模板/…'
带有

  • 'text!/..//templates/home/homemplate.html'
  • 'text!//templates/home/homemplate.html'

发布在堆栈溢出上的问题主体应包含与当前问题相关的数据。链接到外部站点是可以的,只要它们不替换应该存在问题的内容。在这里,您至少应该有您的RequireJS配置,并显示使用模板的代码。(如果代码很长,仔细缩写就可以了。)