###前提・実現したいこと
Electronでメインプロセスからレンダラープロセスへ通信したい
###発生している問題・エラーメッセージ
Uncaught TypeError: ipc.on is not a function at index.js:4
###該当のソースコード
main.js
js
1'use strict'; 2 3const electron = require('electron'), 4 ipc = require('ipc'), 5 app = electron.app, 6 BrowserWindow = electron.BrowserWindow; 7 8var mainWindow = null; 9 10app.on('window-all-closed', function() { 11 if (process.platform != 'darwin') 12 app.quit(); 13}); 14 15app.on('ready', function() { 16 mainWindow = new BrowserWindow({width: 800, height: 600}); 17 mainWindow.loadURL('file://' + __dirname + '/index.html'); 18 mainWindow.on('closed', function() { 19 mainWindow = null; 20 }); 21 mainWindow.webContents.openDevTools(); 22 23 current.webContents.on('did-finish-load', function() { 24 current.webContents.send('msg', 'ping'); 25 }); 26});
index.html
js
1<!DOCTYPE html> 2<html> 3<head> 4<meta charset="UTF-8"> 5</head> 6<body> 7<h1>Hello, electron!</h1> 8<script src="index.js"></script> 9</body> 10</html>
index.js
js
1const ipc = require('ipc'); 2 3ipc.on('msg', function(event, arg) { 4 console.log(event); 5 console.log(arg); 6});
###試したこと
http://qiita.com/Misumi_Rize/items/dde76dbf89abee13991c
を参考に以下のように書いたのですがエラーになってしました
js
1current.webContents.on('did-finish-load', function() { 2 current.webContents.send('asynchronous-message', 'ping'); 3});
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。