<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <button id="notify_btn">通知消息</button> </body> <script> var btn = document.getElementById('notify_btn') var opetion = { title: '来订单了', body: '内容内容内容' } btn.onclick = function () { new window.Notification(opetion.title, opetion) } </script> </html>