如何在 JavaScript 中访问外部类属性?
例如:
var outer = {
outerField: 15,
inner: {
innerFunc: function () {
// <-- How can I get access to outerField here?
}
}
};
如何在 JavaScript 中访问外部类属性?
例如:
var outer = {
outerField: 15,
inner: {
innerFunc: function () {
// <-- How can I get access to outerField here?
}
}
};
这个(已回答)问题类似,您基本上从外部对象定义内部对象方法以从外部对象获取属性:access javascript parent class properties from subclass
该解决方案有效
var outer = {
outervalue: 3,
inner: {
innerFunc: function () {
// How can I get access to outer_value inside this method
return (this.outervalue);
}.call(outer)
}
};