
vue项目如何实现标题闪烁通知,并且附带声音提示效果!下面web建站小编带大家了解一下!
新建一个Notice组件
<template>
<div>
<audio ref="audio" :src="sound"></audio>
</div>
</template>
<script>
export default {
name: "Notice",
props: {
sound: {
type: String,
default: ''
},
},
data() {
return {
tipTimer: null,
tipTimerCount: 0,
titleOld: null,
}
},
methods: {
tip(msg, type) {
this.doPageTitle(msg, type)
if (this.sound) {
this.doPlaySound()
}
},
doClearTimer() {
clearInterval(this.tipTimer)
this.tipTimer = null
if (this.titleOld) {
window.document.title = this.titleOld
}
this.tipTimerCount = 0
},
doPageTitle(msg, type) {
type = type || '提醒'
if (this.tipTimer) {
this.doClearTimer()
}
this.titleOld = document.title
this.tipTimerCount = 0
this.tipTimer = setInterval(() => {
this.tipTimerCount++
if (this.tipTimerCount % 2 === 0) {
window.document.title = '【' + type + '】' + msg
} else {
window.document.title = '' + msg
}
if (this.tipTimerCount > 6) {
this.doClearTimer()
}
}, 500)
},
doPlaySound() {
let audio = this.$refs.audio
if (!audio) {
return
}
try {
audio.pause()
audio.play()
} catch (e) {}
}
}
}
</script>
Notice组件引用
<noticeCon ref="noticeConRefs" sound="message.mp3"></noticeCon>
调用方法
this.$refs.noticeConRefs.tip('hello','新消息')
element-ui时间选择器el-date-picker默认当前时间至7天之前时间
vue实现表格的编辑,包括选择,合并,拆分,删除行/列,添加行/列
Motion for Vue:一个轻量级且功能强大的Vue3动画库
标签: 通知效果
上面是“vue项目如何实现标题闪烁通知效果(附带声音提示)”的全面内容,想了解更多关于 vuejs 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_2901.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

ScienceDirect官网:一个拥有超过2650种期刊和45000余种图书的平台
Speakr:自动化完成会议录音转写、内容摘要提炼与智能问答等功能
AnuNeko:一个高度个性化和情绪化的对话体验的AI聊天工具
vegaai官网:支持文生图、图生图、风格转换、姿势生图等
Syft APP
GDPval:OpenAI研发推出的全新AI模型经济价值评估框架