为什么requirejs试图将“.js”附加到加载了!text插件的.jst模板文件中
Why is requirejs trying to append a '.js' to .jst template files that are loaded with the !text plugin?
我对模板文件使用.jst扩展名,并使用requirejs文本加载它们! 插件。 例如,
define([
'jquery',
'backbone',
'underscore',
'text!templates/MyView.jst'
],
function($, Backbone, _, templateText) {
return Backbone.View.extend({
template: _.template(templateText),
initialize: function() {
},
render: function() {
}
});
});
当我在本地测试时,这会膨胀。 但是,当我在将静态文件部署到 AWS(应用程序的动态部分在 Heroku 上运行)后尝试执行此操作时,它无法加载 .jst 文件,并且似乎试图将.js附加到其 url。
作为参考,这是我的需求js配置(来自main.js)
requirejs.config({
paths: {
//directories
plugins: "lib/plugins",
//libs
jquery: "lib/jquery/1.7.1/jquery",
underscore: "lib/underscore/1.3.3/underscore",
backbone: "lib/backbone/0.9.2/backbone",
moment: "lib/moment", // date lib
//require plugins
text: "lib/require/plugins/text",
domReady: "lib/require/plugins/domReady"
},
shim: { //specify all non-AMD javascript files here.
backbone: {
deps: ['underscore', 'jquery'],
exports: 'Backbone'
},
underscore: {
exports: '_'
},
moment: {
exports: 'moment'
},
'plugins/jquery.colorbox': ['jquery'],
'util/jquery.dropTree':['jquery'],
'util/common':['jquery']
}
});
我刚刚更新了文本.js自述文件,其中包含解释此问题的信息。它基本上是一种跨域使用文本资源的方法,但它需要构建。有一种方法可以覆盖。详情请见此处:
https://github.com/requirejs/text#xhr-restrictions
相关文章:
- 如何在Angular2中使用jQuery插件
- 可以前端maven插件使用节点,npm已经安装
- 如何使jQuery插件函数可调用以供独立使用,而不在集合上操作
- 我的jQuery插件参数没有正确启动,遇到了问题
- 如何在elfinder插件(一个文件管理器插件)上获得上传前事件
- 如何将输入(type=text)从html表单传递到javascript函数
- 是否有任何snippet或jQuery插件可以列出easylist.txt模式匹配的DOM中的所有元素
- TableExport jquery插件:文件名和扩展名问题
- 如何在使用selectBoxIt JQuery插件时检测选项更改
- jQuery插件-从插件中调用公共方法
- 压缩phonegap中ios的图像插件
- jQuery粘性插件可变顶部间距
- Jquery表单验证插件-如果选中复选框,如何在提交时执行某些操作
- r.js评估'text'插件,尽管在'stubModules'参数
- 为什么requirejs试图将“.js”附加到加载了!text插件的.jst模板文件中
- 使用v8插件实现用于sublime text 2的js插件
- 任何Sublime Text插件都可以用匿名函数自动包装生成的js
- 在使用jQuery Validate插件时,是否有一种简单的方法来改变单选按钮所需的消息TEXT,而不是位置
- Require.js(+text插件)拒绝加载任何外部文本!模板,即使它们位于我自己的主机服务器
- 模板使用RequireJS (text.js插件)和下划线