-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathframeA.html
49 lines (49 loc) · 1.55 KB
/
frameA.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
<!--
* @Author: caizeyong
* @Date: 2019-11-06 16:44:54
* @Description:
-->
<!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>frame a</title>
</head>
<body>
Frame A: <input type="text" id="j_input" value="1">
<script src="./eventBus.js"></script>
<script>
var registed = false
var ipt = document.querySelector('#j_input')
CreatePostMessageEventBus({
success: function () {
registed = true
console.log('注册成功')
},
receive: function (data) {
console.log('接收到数据', data)
if (data.name === 'increase') {
ipt.value = ipt.value*1 + 1
} else if (data.name === 'decrease') {
ipt.value = ipt.value*1 - 1
}
this.send({
name: 'change',
sum: ipt.value
})
},
request: function (cmd) {
console.log('要求派发事件', cmd)
this.send({
name: 'change',
sum: ipt.value
})
},
on: ['increase', 'decrease'],
emit: ['change']
})
</script>
</body>
</html>