电子:通知不是构造函数

Aka*_*uja 2 javascript electron

我正在尝试初始化电子提供的通知对象。但我收到的错误是: Uncaught Exception: TypeError: electron.Notification is not a constructor

我正在这样做Main

代码:

const electron = require('electron');
new electron.Notification({ title: "Cue", body: "Hello" }).show();
Run Code Online (Sandbox Code Playgroud)

电子版: 2.0.2/2.0.3

任何线索或想法?

小智 7

我觉得你应该写

new electron.remote.Notification({....})
Run Code Online (Sandbox Code Playgroud)

代替

new electron.Notification({....})
Run Code Online (Sandbox Code Playgroud)