首页 > 代码库 > html - 自动播放

html - 自动播放

<!DOCTYPE html><html>  <head>    <meta charset="utf-8">    <title>start_vuex</title>  </head>  <body>    <audio style="display:none; height: 0" id="bg-music" loop="loop" preload="auto" src=‘./test.mp3‘> 你的浏览器不支持audio标签 </audio>      </body>  <script>document.addEventListener(DOMContentLoaded, function () {    function audioAutoPlay() {        var audio = document.getElementById(bg-music);            audio.play();        document.addEventListener("WeixinJSBridgeReady", function () {            audio.play();        }, false);    }    audioAutoPlay();});   </script></html>

 

html - 自动播放