javascript">async function helloAsync() {
await new Promise(function (resolve, reject) {
throw new Error('错误');
});
}
helloAsync().then(v => console.log(v))
.catch(e => console.log(e.message));
上面是js文件,下面是html文件
html文件console中啥也没有,也可能是我不会用
javascript"><!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<script>
async function helloAsync() {
await new Promise(function (resolve, reject) {
throw new Error('错误');
});
}
helloAsync().then(v => console.log(v))
.catch(e => console.log(e.message));
</script>
</body>
</html>