12
用这种方式,也可以在类中替换this
var name="window";function createFun(){ this.name="obj"; this.getNameFun=function(that){ return function(){ return that.name; }; }(this);}var obj=new createFun();console.log(obj.getNameFun()); //obj
本文共 319 字,大约阅读时间需要 1 分钟。
12
用这种方式,也可以在类中替换this
var name="window";function createFun(){ this.name="obj"; this.getNameFun=function(that){ return function(){ return that.name; }; }(this);}var obj=new createFun();console.log(obj.getNameFun()); //obj
转载于:https://www.cnblogs.com/frostbelt/archive/2012/03/10/2388713.html