Uncaught DOMException: Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.
解决方法:
使用window.btoa加密失败,报错如下:
Uncaught DOMException: Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.
原因是加密的的字符串中有特殊字符那些,所以得先使用window.encodeURIComponent编码再加密。
var str64 = window.btoa(window.encodeURIComponent(str))