<script src="js/base64.js"></script>
<script>
var theRequest = new Object();
var url='?params=eyJhZHZhbmNlZF9wYXlfcHJpY2UiOjY2NiwiYXV0b19jb2xvciI6IuWNoeWFtumHkSIsImF1dG9fbW9kZWxfbmFtZSI6IjEuNUwg6Ieq5YqoIOe7j+WFuOWeiyIsImZpbmFsX3ByaWNlIjo1NTU1LCJpbnRlcmlvciI6IumAgOaNoui0pyIsInJlYWxfcHJpY2UiOjY2NjYsInJlZmVyX3ByaWNlIjoiMTAuMTnkuIciLCJzZWxsZXJfbW9iaWxlIjoiMTM5ODI2MTUzMDciLCJzZWxsZXJfbmFtZSI6IuiZq+WmueWmuSIsInN1Yl9icmFuZF9uYW1lIjoi5Yev6LaKIiwic3VwcGxpZXJfbmFtZSI6IuW8mOmbheWIq+WFiyIsInllYXIiOiIyMDEzIn0=';
var base = new Base64();
if (url.indexOf("?") != -1) {
var str = url.substr(1);
var strs = str.split("&");
for (var i = 0; i < strs.length; i++) {
theRequest[strs[i].split("=")[0]] = (strs[i].split("=")[1]);
}
}
var result = theRequest.params; //取到=后的值
console.log(result)
var strjson = base.decode(result);//base64解密
console.log(strjson)
var data = JSON.parse(strjson); //这里就报错
console.log(data);
</script>
不能转成json对象 引入了 base64解密插件 求大神帮忙下
慕标琳琳
相关分类