var View = Backbone.View.extend({
id: 'foobar',
param: {
x: this.id // Will be "undefined"
}
});
有没有办法利用this
,使this.param.x
指向,或者与this.id<具有相同的值
?
最佳答案
您不能在静态声明中使用对象的 this
。您可以在方法调用或构造函数中使用代码设置该值,但不能在静态声明中设置。
关于javascript - 将 "this"关键字发送到对象中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12191234/