小编fut*_*502的帖子

电子通知 API“点击”事件不起作用

我有一个问题,实验电子通知 API不提交“点击”事件,或者我只是使用错误,但是我想清楚这是在主进程中运行的新通知系统,而不是在渲染器进程中运行:

我的代码:

notification = new Notification({title: "Message Received",body: "message body"}).show()
// The above works and a notification gets made

notification.on('click', (event, arg)=>{
  console.log("clicked")
})

// The above gives an error about 'on' not being defined
Run Code Online (Sandbox Code Playgroud)

尝试的事情:

notification.once('click', (event, arg)=>{
  console.log("clicked")
})
Run Code Online (Sandbox Code Playgroud)
notification.onclick = () =>{
  console.log("clicked")
}
Run Code Online (Sandbox Code Playgroud)

javascript node.js electron

0
推荐指数
1
解决办法
1552
查看次数

标签 统计

electron ×1

javascript ×1

node.js ×1