您的位置:宽带测速网 > 网络知识 > 小程序页面路径参数怎么看

小程序页面路径参数怎么看

2025-06-17 10:29来源:互联网 [ ]

小程序获取当前页面路径及参数的代码:

exportfunctiongetCurrentPageUrlWithArgs(){

constpages=getCurrentPages()

constcurrentPage=pages[pages.length-1]

consturl=currentPage.route

constoptions=currentPage.options

leturlWithArgs=`/${url}?`

for(letkeyinoptions){

constvalue=options[key]

urlWithArgs+=`${key}=${value}&`

}

urlWithArgs=urlWithArgs.substring(0,urlWithArgs.length-1)

returnurlWithArgs

}