微信小程序——获取当前页面路由

版权声明: https://blog.csdn.net/xiasohuai/article/details/84289704

getCurrentPages() 函数用于获取当前页面栈的实例,以数组形式按栈的顺序给出,第一个元素为首页,最后一个元素为当前页面。

let pages = getCurrentPages();
let currPage = null;
if (pages.length) {
   currPage = pages[pages.length - 1];
}
console.log(currPage)   

猜你喜欢

转载自blog.csdn.net/xiasohuai/article/details/84289704