-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
zhangyue0503
committed
Jun 29, 2018
1 parent
782d97e
commit 208bd43
Showing
23 changed files
with
732 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>Document</title> | ||
|
||
</head> | ||
|
||
<body> | ||
|
||
<script> | ||
Promise.all([ | ||
new Promise((s, e) => { | ||
s(); | ||
}), new Promise((s, e) => { | ||
s(); | ||
}), new Promise((s, e) => { | ||
e(); | ||
}) | ||
]).then(() => { | ||
console.log(1); | ||
}).catch(()=>{ | ||
console.log(2); | ||
}); | ||
</script> | ||
</body> | ||
|
||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>Document</title> | ||
|
||
</head> | ||
<body> | ||
|
||
<script> | ||
new Promise((succ,error)=>{ | ||
error('asdasddsd'); | ||
}).then(()=>{ | ||
|
||
}).catch(x=>{ | ||
console.log(x); | ||
return 'asdfasdf'; | ||
}).then(f=>{ | ||
console.log(f); | ||
}) | ||
</script> | ||
</body> | ||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>Document</title> | ||
<style> | ||
*{margin:0;padding:0;list-style: none;} | ||
div{ | ||
width:200px;height:200px;background:#ccc; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<input id='ipt' type="button" value="ddd"> | ||
<div id="div1"></div> | ||
<script> | ||
let index = 0; | ||
let div1 = document.getElementById('div1'); | ||
let ipt = document.getElementById('ipt'); | ||
ipt.onclick = x => { | ||
index++; | ||
new Promise((succ,error)=>{ | ||
index%2==1?succ():error(); | ||
}).then(()=>{ | ||
div1.style.display = 'none'; | ||
},()=>{ | ||
div1.style.display = 'block'; | ||
}); | ||
} | ||
</script> | ||
</body> | ||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>Document</title> | ||
|
||
</head> | ||
|
||
<body> | ||
<script> | ||
var map = new Map(); | ||
|
||
map.set( | ||
[ | ||
['111', 222], | ||
['222', 333] | ||
] | ||
); | ||
console.log(map); | ||
</script> | ||
</body> | ||
|
||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<script> | ||
function showPromise(res){ | ||
return new Promise((resolve,reject)=>{ | ||
resolve(res); | ||
}).then(x=>{console.log(res);}) | ||
} | ||
|
||
showPromise('haha'); | ||
showPromise('haha11'); | ||
|
||
// var pro = new Promise(function(reslove,reject){ | ||
// reslove('heiehiehi'); | ||
// }).then(function(x){ | ||
// alert('成功'+x); | ||
// },function(){ | ||
// alert('失败'); | ||
// }); | ||
|
||
// console.log(pro); | ||
</script> | ||
</body> | ||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<script> | ||
new Promise(function(reslove,reject){ | ||
reslove('heiehiehi'); | ||
}).then(function(x){ | ||
alert(x); | ||
return 'asdfasdf'; | ||
},function(){ | ||
alert('失败'); | ||
}).then(function(x){ | ||
alert(x); | ||
return '1010101'; | ||
}).then(function(x){ | ||
alert(x); | ||
}) | ||
</script> | ||
</body> | ||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>Document</title> | ||
|
||
</head> | ||
|
||
<body> | ||
|
||
<script> | ||
new Promise((success, error) => { | ||
success('123'); | ||
}).then((x) => { | ||
throw x; | ||
return x + 1; | ||
}) | ||
.then((f) => { | ||
console.log(f); | ||
}) | ||
.then(() => {}) | ||
</script> | ||
</body> | ||
|
||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>Document</title> | ||
|
||
</head> | ||
|
||
<body> | ||
|
||
<script> | ||
Promise.resolve('123123111').then((f)=>{ | ||
console.log(f); | ||
}).catch(()=>{ | ||
console.log(123123); | ||
}); | ||
Promise.reject('123123111').then((f)=>{ | ||
console.log(f); | ||
}).catch(()=>{ | ||
console.log(123123); | ||
}); | ||
</script> | ||
</body> | ||
|
||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>Document</title> | ||
|
||
</head> | ||
|
||
<body> | ||
<script> | ||
function ajax(url) { | ||
return new Promise((s, e) => { | ||
var ajax = new XMLHttpRequest(); | ||
ajax.open('get', url, true); | ||
ajax.send(); | ||
ajax.onload = function () { | ||
s(ajax.responseText); | ||
}; | ||
ajax.onerror = function(){ | ||
e(); | ||
} | ||
}).then((text)=>{ | ||
console.log(text); | ||
}).catch(()=>{ | ||
console.log('失败了'); | ||
}); | ||
} | ||
|
||
ajax('http://localhost:3000'); | ||
|
||
|
||
// var ajax = new XMLHttpRequest(); | ||
// ajax.open('get', 'http://localhost:3000', true); | ||
// ajax.send(); | ||
// ajax.onload = function () { | ||
// console.log(ajax.responseText); | ||
// } | ||
// ajax.onerror = function () { | ||
// console.log(ajax.status); | ||
// } | ||
// console.log(ajax.responseText); | ||
// console.log(ajax); | ||
</script> | ||
</body> | ||
|
||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>Document</title> | ||
|
||
</head> | ||
|
||
<body> | ||
|
||
<script> | ||
Promise.race([ | ||
new Promise((s, e) => { | ||
// s('555'); | ||
setTimeout(s,1000,'1'); | ||
}), new Promise((s, e) => { | ||
setTimeout(s,1200,'2'); | ||
}), new Promise((s, e) => { | ||
setTimeout(s,1400,'3'); | ||
}) | ||
]).then((x) => { | ||
console.log(x); | ||
}, () => {}) | ||
</script> | ||
</body> | ||
|
||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const http = require('http'); | ||
|
||
const hostname = '127.0.0.1'; | ||
const port = 3000; | ||
|
||
const server = http.createServer((req,res)=>{ | ||
res.statusCode = 200; | ||
res.setHeader('Content-Type','text/plain'); | ||
res.setHeader('Access-Control-Allow-Origin','*'); | ||
|
||
Object.keys(require.cache).forEach(function(key){ | ||
delete require.cache[key]; | ||
}); | ||
|
||
|
||
|
||
res.end('aaaal;ksjdflkasjdf'); | ||
}); | ||
|
||
server.listen(port,hostname,()=>{ | ||
console.log(`Server running at http://${hostname}:${port}/`) | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>Document</title> | ||
|
||
</head> | ||
<body> | ||
|
||
<script> | ||
// throw 'alakskldjf'; | ||
console.warn('asdfasdf'); | ||
console.error('alskdjflkass'); | ||
console.log(111); | ||
</script> | ||
</body> | ||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>Document</title> | ||
|
||
</head> | ||
|
||
<body> | ||
<script> | ||
|
||
</script> | ||
</body> | ||
|
||
</html> |
Oops, something went wrong.