Javascript YepNope键值对未按预期执行
我开始学习YepNope,有这样一个脚本:Javascript YepNope键值对未按预期执行,javascript,asynchronous,modernizr,yepnope,Javascript,Asynchronous,Modernizr,Yepnope,我开始学习YepNope,有这样一个脚本: yepnope([ { load: 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js', }, { test: true, yep: { 'jquery-ui' : 'js/jquery-ui.js', 'jquery-expandable' : 'j
yepnope([
{
load: 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js',
},
{
test: true,
yep: {
'jquery-ui' : 'js/jquery-ui.js',
'jquery-expandable' : 'js/jquery.expandable.js',
'triggers' : 'js/triggers.js',
'prettify' : 'js/prettify/prettify.js'
},
callback: {
'prettify': function (url, result, key) {
console.log(key + ' loaded ' + result);
prettyPrint();
}
}
}
]);
我只需要一个美容的回电话。但是,运行上述命令会将控制台日志显示为已成功加载,但prettyPrint()未定义
如果我为其他键指定空白函数回调,例如:
yepnope([
{
load: 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js',
},
{
test: true,
yep: {
'jquery-ui' : 'js/jquery-ui.js',
'jquery-expandable' : 'js/jquery.expandable.js',
'triggers' : 'js/triggers.js',
'prettify' : 'js/prettify/prettify.js'
},
callback: {
'jquery-ui': function(url, result, key) {
},
'jquery-expandable': function(url, result, key) {
},
'triggers': function (url, result, key) {
},
'prettify': function (url, result, key) {
console.log(key + ' loaded ' + result);
prettyPrint();
}
}
}
]);
这确实有效。所以,当使用这种语法时,我们是否必须为每个回调指定一个键,即使我们不需要为特定的键指定回调?或者这是YepNope中的一个bug?我也可以在脚本的Modernizr.load版本中复制这个