vue3路由跳转传参

首先在页面引入router

import router from "../../router/index";

然后传值就是

   router.push({
     path:'/addShop',query:{
     id:id}})

在另一个页面接受到的是

在这里插入代码片{
     currentRoute: RefImpl, addRoute: ƒ, removeRoute: ƒ, hasRoute: ƒ, getRoutes: ƒ,}
addRoute: ƒ addRoute(parentOrRoute, route)
afterEach: ƒ add(handler)
back: () => go(-1)
beforeEach: ƒ add(handler)
beforeResolve: ƒ add(handler)
currentRoute: RefImpl
__v_isRef: true
_rawValue:
fullPath: "/addShop?id=10964"
hash: ""
href: "/addShop?id=10964"
matched: (2) [{
     }, {
     }]
meta: {
     }
name: "addShop"
params: {
     }
path: "/addShop"
query: {
     id: "10964"}
redirectedFrom: undefined
__proto__: Object
_shallow: true
_value: {
     fullPath: "/addShop?id=10964", path: "/addShop", query: {
     }, hash: "", name: "addShop",}
value: Object
__proto__: Object
forward: () => go(1)
getRoutes: ƒ getRoutes()
go: (delta) => routerHistory.go(delta)
hasRoute: ƒ hasRoute(name)
install: install(app) {
      const router = this; app.component('RouterLink', RouterLink); app.component('RouterView', RouterView); app.config.globalProperties.$router = router; Object.defineProperty(app.config.globalProperties, '$route', {
      enumerable: true, get: () => {
     }
isReady: ƒ isReady()
onError: ƒ add(handler)
options: {
     history: {
     }, routes: Array(3)}
push: ƒ push(to)
removeRoute: ƒ removeRoute(name)
replace: ƒ replace(to)
resolve: ƒ resolve(rawLocation, currentLocation)
__hasDevtools: true
__proto__: Object

这样的一个数据,在数据结构中找

router.currentRoute._rawValue.query.id

就是我们穿过来的值

你可能感兴趣的:(vue3路由跳转传参)