如图:
首页为 域名+/index.html
如果点击跳转进入了下一个页面
如:登录页
在跳转的时候,后面加上一个redirect的参数。redirect这个参数指向上一个页面的路径
这时,进入了登录页,登录页的url:
后面的redirect 就是上一个页面的url(localhost:2000/index.html)
点击登录页
跳转到上一个页面,就是用下面的这句
// 获取url参数
getUrlParam:function(name){
var reg = new RegExp('(^|&)'+name+'=([^&]*)(&|$)');
var result = window.location.search.substr(1).match(reg);
return result ? decodeURIComponent(result[2]) : null;
},
利用getUrlParam方法拿到redirect参数的值(localhost:2000/index.html)
这样就跳转回上一个页面啦