-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
62 lines (62 loc) · 1.95 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<script>
(function () {
var hm = document.createElement('script');
hm.src = 'http://localhost:4000/hm.js?name=chovrio&only=1';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
</head>
<body>
<button eat="吃饭">路由跳转</button>
<button eat="吃饭">报错</button>
<button eat="吃饭">再错</button>
<button
data-chovrio="{'name':'chovrio','age':'20', 'type':'eat', 'event':'click'}"
>
测试
</button>
<script>
const btn = document.querySelectorAll('button');
btn[0].onclick = () => {
history.pushState({ name: 'chovrio' }, 'test', '/');
// fetch("http://111111");
// throw new Error("错误发生了");
};
btn[1].onclick = () => {
throw new Error('错误发生了');
};
btn[2].onclick = () => {
fetch('http://111111')
.then((res) => {
console.log(res);
return true;
})
.catch((e) => {
console.log(e);
Promise.reject(e);
});
};
window.addEventListener('unhandledrejection', (e) => {
console.log('我是reject', e);
});
window.addEventListener('error', (e) => {
console.log('我是error', e);
});
let obj = { name: 'chovrio', age: '20', type: 'eat', event: 'click' };
// document.addEventListener('click', (e) => {
// const json = JSON.parse(
// e.target.getAttribute('data-chovrio').replace(/'/g, `"`)
// );
// console.log(json, typeof json);
// });
</script>
</body>
</html>