Vue 中 route.path 和 route.fullPath 的区别

  route.pathroute.fullPath是Vue Router中route对象的两个属性,用于获取当前路由的路径信息,区别如下:

     1. route.path 只包含从基本URL后开始的路径,假设基本URL(base URL)为 /app,并且当前路由为 /app/home?a=1,那么route.path的值将是 /home;

  2.route.fullPath 包含从基本URL后开始的路径,假设基本URL(base URL)为 /app,并且当前路由为 /app/home?a=1,那么route.path的值将是 /home?a=1;

 如:

//路径:http://127.0.0.1:3000/home?a=1
console.log(route.path)// 输出 /home
console.log(route.fullPath)// 输出 /home?a=1

猜你喜欢

转载自blog.csdn.net/qq_68155756/article/details/131716281