字符串转base64
encodeURI 先把字符串作为 URI 进行编码。
如果有“中文”直接使用btoa会报错。
const str:string = encodeURI('http://www.baidu.com');
const target:string = window.btoa(str);
base64转字符串
可对 encodeURI() 函数编码过的 URI 进行解码
const urltar:string = window.atob(target);
const url:string = decodeURI(urltar); // 'http://www.baidu.com'