![](https://i-blog.csdnimg.cn/blog_migrate/7017a26b5fa456ef1857f356a526d4e2.png)
<view bindtap="showPageInfo">获取当前页带参数的url</view>
// 1 点击事件
showPageInfo(){
var aa=this.getCurrentPageUrlWithArgs();
console.log("aa===",aa);
},
// 2 获取当前页带参数的url
getCurrentPageUrlWithArgs: function() {
var pages = getCurrentPages() //获取加载的页面
var currentPage = pages[pages.length - 1] //获取当前页面的对象
var url = currentPage.route //当前页面url
console.log("url====", url);
var options = currentPage.options //如果要获取url中所带的参数可以查看options
console.log("options====", options);
//拼接url的参数
var urlWithArgs = url + '?'
for (var key in options) {
var value = options[key]
urlWithArgs += key + '=' + value + '&'
}
urlWithArgs = urlWithArgs.substring(0, urlWithArgs.length - 1)
return urlWithArgs
},
![](https://i-blog.csdnimg.cn/blog_migrate/fe1cc6adb26e16c0ddee003b03dc1f9c.png)