Home > Article > Web Front-end > How to get the current page route in Uniapp
Uniapp’s method of getting the current page route: 1. Use getcurrentpages to get all arrays first, and get the last array, and then get the route; 2. Get the current page route directly, the code is [let curRoute = this. $mp.page.route;].
The operating environment of this tutorial: windows7 system, uni-app2.5.1 version. This method is suitable for all brands of computers.
Recommended (free): uni-app development tutorial
##Uniapp’s method of obtaining the current page route:
Method 1:
Use the official method getcurrentpages to get all the arrays first, then get the last array, and then get the route. Of course, there are other attributes that can be used, you can do it by yourself Print and viewlet routes = getCurrentPages(); // 获取当前打开过的页面路由数组 let curRoute = routes[routes.length - 1].route // 获取当前页面路由,也就是最后一个打开的页面路由The following is the array object returned by the
getcurrentpages() method. Each object is actually the object of the opened page
Method 2:
Use the official$mp variable to obtain it. In fact, it is basically the same as the above method, except that the method is mounted. In $mp
let curRoute = this.$mp.page.route; // 直接获取当前页面路由the following is the object returned by
this.$mp object, which is actually the webview object of the current page
The above is the detailed content of How to get the current page route in Uniapp. For more information, please follow other related articles on the PHP Chinese website!