閱讀422 返回首頁    go 阿裏雲 go 技術社區[雲棲]


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

  上一篇:go 瀏覽器 CSS 兼容寫法的測試總結
  下一篇:go PHP截取含中文的混合字符串長度的函數