Jarry Roxwell Asked:2020-06-29 07:13:03 +0000 UTC2020-06-29 07:13:03 +0000 UTC 2020-06-29 07:13:03 +0000 UTC 在对象方法中使用 this 时的父对象 772 再会。 A={ b:1, c:{ z:0, f:function(){return this;} } } 当被调用时,A.c.f()指代c,如何让它A.c.f()指代一个对象A? javascript 2 个回答 Voted user207618 2020-06-29T09:59:04Z2020-06-29T09:59:04Z 它? let A={ b:1, c:{ z:0, f:function(){return this;} } }; console.info(A.c.f.call(A)); Best Answer user176262 2020-06-29T09:48:28Z2020-06-29T09:48:28Z function createA() { var A = { b: 1, c: { A: null, z: 0, f: function() { return this.A; } } }; A.c.A = A; return A; } var A = createA(); console.log(A.c.f()); var A = { b: 1, c: { A: null, z: 0, f: function() { return A; } } }; console.log(A.c.f());
它?