<template>
<el-button style="margin-left: 30px;" type="primary" size="small" @click="handleSearch" icon="el-icon-search">查 询 </el-button> </template>
<script>
export default { methods:{
// 通知触发事件 handleSearch() { this.setNotification("信息哦") }, //编辑通知内容并加上各个点击事件等 后期控制点击通知跳转到文章 setNotification(content) { let _this = this let notify = new Notification('新消息来啦!', { body: content, lang: 'zh-CN', }) notify.onshow = function() { console.log('通知显示!') } notify.onclick = function() { console.log('windows弹窗点击通知') window.focus() window.location.href = 'https://www.baidu.com/' notify.close() } notify.onerror = function() { console.log('通知错误!') // 手动关闭 notify.close() } notify.onclose = function() { console.log('通知关闭') } }, } } </script>
效果图:
点击弹窗 会跳到百度,我自己设置的。