根据这个Mozilla 文档,arguments
可以设置:
arguments[1] = 'new value';
但我jshint
拒绝接受。是否可以设置参数?
这就是我现在必须做的:
Handlebars.registerHelper('propPartial', function(property, options) {
var name = Ember.Handlebars.get(this, property);
// I have to do this because arguments[0] = name; does not work, contrary to what is stated here:
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions_and_function_scope/arguments
var args = [], i, l;
args.push(name);
for (i = 1, l = arguments.length; i < l; i++) {
args.push(arguments[i]);
}
return Ember.Handlebars.helpers.partial.apply(this, args);
});
更新,供参考
感谢@TJCrowder,这是工作代码,愚弄jshint
:
Handlebars.registerHelper('propPartial', function(property, options) {
var name = Ember.Handlebars.get(this, property);
var args = arguments;
args[0] = name;
return Ember.Handlebars.helpers.partial.apply(this, args);
});