<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
body {
font-family: "Microsoft YaHei", serif;
}
body, dl, dd, p, h1, h2, h3, h4, h5, h6 {
margin: 0;
}
ol, ul, li {
margin: 0;
padding: 0;
list-style: none;
}
img {
border: none
}
</style>
</head>
<body>
<div id="wrap"></div>
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
<script>
// setTimeout(function () {
// console.log(1);
// setTimeout(function () {
// console.log(2);
// setTimeout(function () {
// console.log(3);
// setTimeout(function () {
// console.log(4);
// },1000)
// },1000)
// },1000)
// },1000);
// 换成Promise
new Promise((resolve, reject)=>{
setTimeout(function () {
console.log(1);
resolve();
},1000)
}).then(()=>{
return new Promise((resolve, reject) => {
setTimeout(function () {
console.log(2);
resolve();
},1000)
})
}).then(()=>{
return new Promise((resolve, reject) => {
setTimeout(function () {
console.log(3);
resolve();
},1000)
})
}).then(()=>{
return new Promise((resolve, reject) => {
setTimeout(function () {
console.log(4);
resolve();
},1000)
})
})
</script>
</body>
</html>
Python3Turtle