如何从回调测试中访问土豆,土豆匿名函数无法修改?绑定等不起作用,有人有想法吗?//This cannot be changed!function(a){ // let potatos = { count: 999 } // let garden = { /** * */ callbacks: [], /** * */ showInfo: function() { this.callbacks.forEach((cb) => { cb(); }) } } // global.garden = garden;//or window.garden}();/** * */function test() { console.log(potatos);//Error}garden.callbacks.push(test);garden.showInfo();
添加回答
举报
0/150
提交
取消