温馨提示×

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

小新
151
2021-03-19 13:28:50
栏目: 云计算

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

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

export function getCurrentPageUrlWithArgs() {

const pages = getCurrentPages()

const currentPage = pages[pages.length - 1]

const url = currentPage.route

const options = currentPage.options

let urlWithArgs = `/${url}?`

for (let key in options) {

const value = options[key]

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

}

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

return urlWithArgs

}


0