Templates 使用backbone.js';text.js插件无法访问模板
我得到错误get localhost:8080/scripts/templates/home/homeTemplate.html 404(未找到) 不知道为什么会这样。基于本教程,我觉得文件放在了正确的位置 github存储库就在这里 我像这样引用模板 “文本!templates/home/homemplate.html'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
从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
被解释为错误的URLscripts/templates/home/home/homemplate.html
如果不想修改main.js
脚本,
您可以通过以下方式指定homemplate.html
的正确位置:
替换”文本!模板/…'
带有
或'text!/..//templates/home/homemplate.html'
'text!//templates/home/homemplate.html'