标签:foreach list any 函数 dde event listen index cto
// ts版-vue private justPalyOne() { const audios = document.querySelectorAll("audio"); // 暂停函数 const pauseAll = (exclude: any): any => { audios.forEach((audio, index) => { if (exclude !== index) { audio.pause(); } }); }; audios.forEach((audio, index) => { audio.addEventListener("play", ()=>{pauseAll(index)}); }); }
// 普通js版 const justPalyOne = () => { const audios = document.querySelectorAll("audio"); // 暂停函数 const pauseAll = (exclude)=> { audios.forEach((audio, index) => { if (exclude !== index) { audio.pause(); } }); }; audios.forEach((audio, index) => { audio.addEventListener("play", ()=>{pauseAll(index)}); }); }
标签:foreach list any 函数 dde event listen index cto
原文地址:https://www.cnblogs.com/dshvv/p/14707953.html