使用區別:
params要用name來引入,使用 this.$route.params 來獲取。
query要用path來引入(name也可以), 使用 this.$route.query來獲取。
外觀展示區別:
query同ajax中get的URL傳參,瀏覽器地址欄中顯示參數。
params則類似於post。URL上看不到參數,缺點刷新後獲取的值爲undefiend
推薦使用query,遇到問題也好排查
如何使用:
this.$router.push(`/describe/${id}`) // 或 this.$router.push({ path: `/describe/${id}` }) // 或 this.$router.push({ name: 'Describe', params: {id} }) // 或 this.$router.push({ path: '/describe', query: {id} })
.