H5 API编码、解码

方式一、
decodeURI 解码 encodeURI 编码
方式二、 var str = 'hello'; //加密 data base 64编码 组成部分 0-9 a-z A-Z +/ = 64位个字符 var str1 = window.btoa(str); console.log( str1 ); var str2 = 'hello你好'; var uri = encodeURIComponent(str2); // 编码 //console.log( uri ) var str2 = window.btoa(uri); // 中文不能直接编码 console.log( str2 ); var str3 = 'aGVsbG8lRTQlQkQlQTAlRTUlQTUlQkQ='; // data base 64编码 var newStr3 = window.atob(str3); //解码 var newStr4 = decodeURI(newStr3); console.log( newStr4 )

猜你喜欢

转载自www.cnblogs.com/Dyla/p/9939409.html
今日推荐