微信小程序获取当前页面路径及参数的代码如下:
const pages = getCurrentPages() const currentPage = pages[pages.length - 1] const url = currentPage.route const options = currentPage.options let urlargs = `/${url}?` for (let key in options) { const value = options[key] urlargs += `${key}=${value}&` } urlargs = urlargs .substring(0, urlargs .length - 1) console.log(urlargs) // /pages/index/task/task?identityTask=2&taskId=e92d6acf95f54ea494a73e443df7c45e