原来的代码是这样的:
<audio src="images/caihong.mp3" autoplay loop id="musicAudio"></audio>
经过各种资料和问答,最后找到了解决办法,就是加入如下js代码:
<script> document.addEventListener('DOMContentLoaded', function() { var audio = document.getElementById('musicAudio'); function audioAutoPlay() { audio.play(); document.addEventListener("WeixinJSBridgeReady", function(){ audio.play(); }, false); } audioAutoPlay(); }); </script>