router和route 區別:
1、跳轉到當前路由的地址:
不傳參的形式: this.$router.push('/index')
直接添加路徑: this.$router.push('/index?from=login')
query傳參:
this.$router.push({
path:'/index',
query:{
from:'login' // 參數名稱
}
})
params傳參:
this.$router.push({
path:'index', // name
params:{
from:'login' // 參數名稱
}
})
2、獲取當前路由參數: this.$route.params.from
3、獲取當前路由id: this.$route.params.id
4、獲取當前路由地址:this.$route.path