ThinkPHP3.2.3中URL带参数跳转

ThinkPHP框架针对前端页面跳转,给出了一种路由方法,通过{:U('模块/控制器/方法')}来跳转到对应的页面中,当这种方法在带有参数并在JS中使用的时候这里给出两种方式,比如说,当控制器为index,方法为index,且参数有两个a1和a2,按照框架的方式,我们在JS中使用应该这样写:

//字符串拼接方式
window.location.href = "{:U('index/index?a1="+x+"&a2="+y+"')}";
//使用replace方法
var str = "{:U('index/index?a1=x&a2=y')}";
str = str.replace("x",x);
str = str.replace("y",y);
window.location.href = str;
发布了65 篇原创文章 · 获赞 58 · 访问量 10万+

猜你喜欢

转载自blog.csdn.net/AngelLover2017/article/details/83342834