Uncaught (in promise) DOMException: play() failed because the user didn’t interact with the document first. https://goo.gl/xX8pDD
报这个错是因为 在最新版的Chrome浏览器(以及所有以Chromium为内核的浏览器)中,已不再允许自动播放音频和视频。就算你为video或audio标签设置了autoplay属性也一样不能自动播放
在我项目中的原因是因为我把播放声音的按钮设置为true,进入页面就会直接触发,所以犯了上面的错。我的解决方法是将初始播放按钮设置为false,就欧克了
参考:https://blog.csdn.net/weixin_45651609/article/details/120237623?ops_request_misc=&request_id=&biz_id=102&utm_term=Uncaught%20(in%20promise)%20DOMExcep&utm_medium=distribute.pc_search_result.none-task-blog-2allsobaiduweb~default-5-120237623.nonecase&spm=1018.2226.3001.4187

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐