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','新消息')
Motion for Vue:一个轻量级且功能强大的Vue3动画库
el-table利用:row-style="rowClass"设置指定行变色
一款免费开源效果酷炫的 Vue / React 大屏数据展示组件库——DataV
上面是“vue项目如何实现标题闪烁通知效果(附带声音提示)”的全面内容,想了解更多关于 vuejs 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_2901.html
workflows工作流
一个可爱的人形小机器人和一只蜗牛在森林
小丑鱼马林在鱼缸里游来游去ComfyUI工作流
一只竹节虫ComfyUI工作流
一杯咖啡蒸汽形成云ComfyUI工作流
森林里一只空灵的犀鸟ComfyUI工作流
红伞伞蓝杆杆云南蘑菇群ComfyUI工作流
一条色彩斑斓的超现实小孔雀鱼ComfyUI工作流
晚上樱花狐狸ComfyUI工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

iframe开发admin后台
纯css制作卡通头像(随鼠标转头)
HTML5 Canvas 刻度尺
js实现table表格动态新增行和列表
用ascii字符画图像
会议人员60s签到倒计时插件
css3做一个风雨雷电天气动态图标
利用canvas画几个好玩的星云物种











