好吧,他才是关键人物。我使用curl.js作为我的AMD加载程序,但我不太喜欢"cram“,因为它需要在unix上运行,而且我正在Windows上进行开发。因此想到了来自r.js库的nodeJS适配器,因为节点已经为RequireJS设置了二进制文件。
现在,当前版本(1.6.4)中的jQuery不是有效的AMD模块(版本1.7),而且jQueryUI组件中存在依赖关系,所以我不得不假装如下:
curl( [js!Core/jquery.js] )
.then( function() {
define('jquery', function() { return jQuery; });
})我的申请对此很满意。但是,使用r.js (版本0.26.0)在此部分失败,有以下错误:
Tracing dependencies for: boot
function (){return jQuery}
node.js:207
throw e; // process.nextTick error, or 'error' event on first tick
^
ReferenceError: jQuery is not defined
at eval at <anonymous> (r.js:7468:30)
at main (r.js:770:33)
at callDefMain (r.js:840:18)这是我的app.build.js
({
appDir: '../',
baseUrl: 'Scripts/',
paths: {
'link': '../../../Lib/@Javascript Libs/curl.js/src/curl/plugin/link.js'
},
dir: 'built',
optimize: 'none',
modules: [
{ name: 'boot' }
]
})下面是完整的参考boot.js (coffeescript):
require([
'link!styles/main.css'
'js!Core/jquery.js!order'
'js!Core/underscore.js!order'
'js!Core/backbone.js!order'
]).then ->
define 'jquery', -> jQuery
.next(['Router/MainRouter'])
.then (MainRouter) ->
new MainRouter()
Backbone.history.navigate('home') unless Backbone.history.start(
pushState: false
)事先谢谢你给出的任何线索.
发布于 2011-10-03 22:55:43
对,是这样。RequireJS在其全局requirejs() (又名require())函数上使用了不同的语法。RequireJs也没有"js!“插件内置。您可能必须在您的配置中包含到它的路径。您还可以对非模块javascript文件使用RequireJS的语法。
另外:CRM0.2将支持使用Rhino的Windows环境。我们正在为CRM0.2编写测试,很快就会发布它。
RequireJS语法(删除js!前缀和包含.js扩展):
require([
'link!styles/main.css'
'order!Core/jquery.js'
'order!Core/underscore.js'
'order!Core/backbone.js'
], function (maincss, jQuery, underscore, backbone) {
// do something here
});https://stackoverflow.com/questions/7625264
复制相似问题