DOMException: Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.
时间: 2024-06-13 07:06:31 浏览: 291
DOMException: play() failed because the user didn‘t interact wit
DOMException: Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.这个错误通常是由于使用atob()函数解码字符串时,字符串没有正确编码导致的。解决这个问题的方法是使用decodeURIComponent()和escape()函数对字符串进行编码和解码,具体方法如下:
```javascript
var bstr = decodeURIComponent(escape(atob(str)));
```
其中,str是需要解码的字符串。这样就可以避免出现DOMException: Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.这个错误了。
阅读全文