Last active
September 13, 2016 09:14
-
-
Save lichenbuliren/d612cecd1cf7db00d63bae23a1596514 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 倒计时 | |
* @param {[type]} countTime 倒计时时间 | |
* @param {[type]} perFn 每秒执行的函数 | |
* @param {[type]} complate 倒计时完成函数 | |
* @return {[type]} [description] | |
*/ | |
function countDown(countTime, perFn, complate) { | |
var count = countTime; | |
countFn(count); | |
function countFn(count) { | |
if (count == 0) { | |
complate && complate(); | |
return; | |
} else { | |
count--; | |
perFn(count); | |
setTimeout(function() { | |
countFn(count); | |
}, 1000); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment