-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: #32 The rendering process ipc listens for adding a frameId group.
Add a frame object to implement the ipc target.IWindow interface
- Loading branch information
Showing
3 changed files
with
76 additions
and
26 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
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
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"> | ||
<title>js-to-go</title> | ||
</head> | ||
<body style="margin: 0px;padding: 0px;"> | ||
JS中监听事件,Go中调用<br> | ||
<div id="message"></div> | ||
<script type="application/javascript"> | ||
function clearMessage() { | ||
document.getElementById("message").innerHTML = ""; | ||
} | ||
|
||
function writeMessage(data) { | ||
let message = document.getElementById("message"); | ||
message.innerHTML = message.innerHTML + data + "<br>" | ||
} | ||
|
||
//ipc.on函数有2个参数 | ||
//参数1 事件名 必填 string类型 | ||
//参数2 回调函数 非必填 function类型, go传递的参数 | ||
ipc.on('js-on-event-demo', function (p1, p2, p3) { | ||
writeMessage("js-on-event-demo Go传递过来的数据: " + p1 + " p2: " + p2 + " p3: " + p3) | ||
}) | ||
//带有返回值 | ||
ipc.on('js-on-event-demo-return', function (p1, p2) { | ||
writeMessage("js-on-event-demo-return-Go传递过来的数据: " + p1 + " p2: " + p2) | ||
//该返回值将返回到go中 | ||
return 'js返回的数据: ' + p1 | ||
}) | ||
</script> | ||
</body> | ||
</html> |