422
技術社區[雲棲]
javascript 延時執行函數
延時執行函數,貌似有些多此一舉, 也許還是有點用 記在這兒
var test = {
delay : function(lifetime){
var data;
setTimeout(function(){
for (name in test.methods) {
eval("data = test.methods."+ name +"();");
}
}, lifetime);
return this;
},
methods : {},
register : function(name, callback){
eval("this.methods."+ name +" = callback;");
return this;
},
output1 : function(message){
this.register("output1", function(){ alert(message); });
return this;
},
output2 : function(message){
this.register("output2", function(){ alert(message); });
return this;
}
}
test.delay(3000).output1("aaa").output2("bbb");
最後更新:2017-04-03 12:54:58