我想从类中调用一个函数(带参数).但是,该函数应作为变量传递给类.
someObject = {
itWorked:function(answer){
alert(answer);
},plugins:{
somePlugin:function(){
var callback;
this.doSomething = doSomething;
function setCallback(c){
callback = c;
}
function doSomething(){
var answer = "hello";
[callback](answer); // how do I call this?
}
}
},widgets:{
something:function(){
var doIt = new someObject();
doIt.setCallback(someObject.itWorked()); // how do I send this?
doIt.doSomething();
}
}
}
最佳答案
原文链接:https://www.f2er.com/js/429499.html