木偶.js需要.js模板路径错误
Marionette.js Require.js Template Path Error
>我的 tpl 有以下目录结构:
-src
-assets
-js
-lib
[files]
-src
-templates
-common
builder_regions.tpl
我的要求配置是:
require.config({
baseUrl:'src/assets/js',
paths: {
backbone: 'lib/backbone',
jquery: 'lib/jquery.min',
'jquery-ui': 'lib/jquery-ui-1.10.4.custom.min',
underscore: 'lib/underscore.min',
modernizr: 'lib/modernizr.min',
'magnific-popup': 'lib/magnific-popup.min',
text: 'src/assets/jslib/text',
marionette: 'lib/backbone.marionette.min',
tpl: 'lib/underscore-tpl'
},
shim: {
jquery: {
exports: '$'
},
underscore: {
exports: '_'
},
backbone: {
deps: [ 'jquery', 'underscore' ],
exports: 'Backbone'
},
marionette: {
deps: [ 'jquery', 'underscore', 'backbone' ],
exports: 'Marionette'
},
'jquery-ui': {
deps: [ 'jquery' ],
exports: '$ui'
},
'magnific-popup': {
deps: [ 'jquery' ],
exports: 'magnificPopup'
},
tpl: [ 'text' ]
}
});
我的需求模块设置为:
define([ 'tpl!src/templates/common/builder_regions.tpl', function( Marionette, layoutTpl ) {
console.log( 'did not throw' );
});
当我访问该模块时,出现以下错误:
GET http://localhost:3000/src/assets/js/src/tpl.js 404 (Not Found)
为什么当我在require.config中提供路径时,文件tpl.js被引用?谢谢!
如果你的underscore-tpl.js
是这个,那么你不需要它的shim
配置,因为它会自己调用define
。如果对不需要填充程序的内容使用 shim
配置,则 RequireJS 的行为可能会很奇怪。
另一件事与您在此处报告的问题无关,但可能会给您带来麻烦:jQuery 至少从 1.9 版本开始就不需要shim
。因此,如果您使用的版本为>= 1.9,则应删除 jquery
的shim
。
试试这个:
define(['marionette', 'tpl!src/templates/common/builder_regions.tpl'], function( Marionette, layoutTpl ) {
console.log( 'did not throw' );
});
相关文章:
- 如何在d3.js中返回路径的y坐标
- JS文件的路径正在消失
- D3.js剪辑路径截断了我的图的边缘
- googlemarkercluster.js库的备用源路径是什么
- 最短路径算法js错误
- 如何在three.js中加载指定文件内容而非路径的三维模型
- 如何为JS模块添加包含路径
- 调用后端、多路径变量、Ext Js
- 纸张.js路径数据动画在帧和鼠标拖动
- 要求无法识别 JS 路径
- 传单.js路径点击移动设备
- 节点中的 Web 服务器.js路径中的错误
- 为什么纸张.js路径创建在 iOS 设备上不起作用
- 有没有一种方法可以在express.js路径中编写html(或jade等)
- 使用当前的require.js路径获取jquery load/get
- _references.js路径不合法
- Raphael-使用transform缩放js路径-意想不到的结果
- D3.js "路径"无效值;属性……“但图表仍在更新
- Gulp没有给index.html添加正确的css/js路径
- 如何使D3.js路径生成器追加两点