路由跳轉以及傳遞引數

2021-08-28 21:33:25 字數 521 閱讀 3499

路由的跳轉

1.

this.$router.push();

2.使用前需確定在定義路由時定義了name

this.$router.push();

路由傳遞引數

1.

傳遞this.$router.push(})

獲取this.$route.params.search

2.通過path攜帶的引數

傳遞this.$router.push()

獲取 this.$route.params.id

注意此方法使用時需在路由path中配置 /:id

3.通過query來傳遞引數,使用此方法傳遞的引數會出現在url位址中

傳遞this.$router.push(});

獲取this.$route.query.id;

this.$route.query.id2;

Vue路由跳轉傳遞引數()

需求 在單頁應用中,從a頁面跳轉到b頁面需要攜帶部分引數,具體操作方法有以下幾種 方法1 使用 router進行跳轉 step1 在router.js中定義攜帶引數的名稱 step2 在a頁面跳轉時攜帶引數 let id 0 this.router.push step3 在b頁面接收引數 let i...

react路由跳轉傳遞引數

需求 路由跳轉的時候將引數傳遞給跳轉之後的頁面。路由 方案一 使用query,特點是引數會出現在url上,重新整理頁面資料不會丟失 browserhistory.push 取值 browserhistory.push 取值 this.props.location.state.deliverypric...

vue 路由跳轉以及引數獲取

路由跳轉 query傳參 this.router.push query傳參 獲取引數 const id this.route.query.id 路由跳轉 params傳參 this.router.push params傳參 獲取引數 const id this.route.params.id 區別 ...