鍍金池/ 問答/HTML/ vue-router 路由參數(shù)加在#號和路徑前面

vue-router 路由參數(shù)加在#號和路徑前面

訪問http://localhost/?s=abc
希望跳轉(zhuǎn)http://localhost/#/home/?s=abc
實際跳轉(zhuǎn)http://localhost/?s=abc#/home

主要是想通過this.$route.query來獲取路由參數(shù),現(xiàn)在這種情況下不知道要怎么獲取。

vue-router是這么寫的`

{ 
  path: '/',
  redirect: '/home'
},
{
  path: '/home',
  name: 'Home',
  component: Home
},`
回答
編輯回答
淺淺

vue-router認為#后邊的是路由,很明顯按照你實際跳轉(zhuǎn)的地址,vue-router認為你的路由后邊是沒有參數(shù)的。建議用js原生獲取window.location.search試試

2018年3月30日 14:02
編輯回答
拽很帥

解決了嗎樓主,我也碰到了這個問題

2017年2月17日 15:09
編輯回答
過客
http://localhost/?s=abc你初始的這個路由是你在什么地方定義過吧
2017年3月24日 07:32