×

Vue

uniapp获取当前路径

admin admin 发表于2024-12-13 浏览413 评论0
// 获取当前页面栈数组
const pages = getCurrentPages();

// 获取当前页面(数组中的最后一个)
const currentPage = pages[pages.length - 1];

// 获取当前页面路径
const currentPath = currentPage.route;

// 全部路径
const fullPath =  pages[pages.length - 1].$page.fullPath;

console.log(currentPath);