$router 和 $route的區別
$route為當前router跳轉對象里面可以獲取name、path、query、params等
$router為VueRouter實例,想要導航到不同URL,則使用$router.push方法
返回上一個history也是使用$router.go方法
$router.push()
1.params 傳參
注意⚠️:patams傳參 ,路徑不能使用path 只能使用name,不然獲取不到傳的數據
this.$router.push({name: 'index', params: {id: 1}})
取數據:this.$route.params.id
2.query傳參
this.$router.push({path: 'good', query: {id: 2}})
取數據:this.$route.query.id