string
string
相关的方法
base64Decode
该函数用于解码 Base64
函数参数和返回值
js
/**
* @param {string} str 要解码的 base64
* @return {string}
*/
展示源码
ts
export function base64Decode(str: string): string {
const value = window
.atob(str)
.split('')
.map((c: string): string => '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2))
.join('');
return decodeURIComponent(value);
}
代码用例
js
const myStr = base64Decode('SGVsbG8sIHdvcmxk');