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