function doubleAfter2seconds(num) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve(2 * num)
}, 2000);
} )
}
async function timeout() {
let result = await doubleAfter2seconds(30);
console.log(result);
return "是"
}
timeout().then(result => {
console.log(result);
})
.......................................................
var data = [
'https://xxx.com/img/logo.jpg',
'https://xxx.com/img/bg.jpg',
'https://xxx.com/css/main.css',
'https://xxx.com/css/animate.css',
'https://xxx.com/js/jquery.js',
'https://xxx.com/js/form.js',
]
data.forEach(request)
function request(url) {
alert(url)
}
网友评论