+
95
-

new Audio("tewt.mp3")报错DOMException: play() failed because the user didn't interact with the documen

今天用js调用Audio来play声音的时候报错了

OMException: play() failed because the user didn't interact with the document first,这个咋解决呢?

网友回复

+
15
-

这个由于chrome86版本之后默认打开网页后不允许自动播放音频,需要用户点击交互才能播放,可以增加一个播放按钮,再触发Audio播放。

我知道答案,我要回答