标签:time eve window on() onload async settime ntb set
window.onload = function(){
document.getElementById(‘bottom‘).addEventListener(‘click‘, function(){
alert(11);
});
}
var sleep = function (time) {
return new Promise(function (resolve, reject) {
setTimeout(function () {
let data = ‘db‘;
resolve(data);
}, time);
})
};
var sleepAgain = function (time) {
return new Promise(function (resolve, reject) {
setTimeout(function () {
resolve();
}, time);
})
};
var start = async function () {
// 在这里使用起来就像同步代码那样直观
console.log(‘start‘);
let result = await sleep(3000);
console.log(result);
console.log(‘again‘);
await sleepAgain(3000);
console.log(‘end‘);
};
start();
标签:time eve window on() onload async settime ntb set
原文地址:http://www.cnblogs.com/winyh/p/6900220.html