如何从其它页面跳转到vue里?
发布网友
发布时间:2022-04-20 14:54
我来回答
共1个回答
热心网友
时间:2024-03-30 17:06
跳转:
1、直接跳转
<router-link to="/detail/one">link跳转 </router-link>
2、携带参数跳转
<router-link :to="{path:'/detail/two', query:{id:1,name:'vue'}}">link跳转 </router-link>
3、打开新窗口跳转
<router-link :to="{path:'/detail/three', query:{id:1,name:'vue'}}" target="_blank">link跳转</router-link>
获取参数:
id = this.$route.query.id
1、path query 跳转:
this.$router.push({path: "/detail", query: {id: e}})
获取参数:
id = this.$route.query.id
2、name params 跳转:
this.$router.push({name: "/detail", params: {id: e}})
获取参数:
id = this.$route.params.id
跳转:
const new = this.$router.resolve({name: '/detail', params: {id: e}})
或
const new = this.$router.resolve({path: '/detail', query: {id: e}})
window.open(new.href,'_blank')
获取参数:
id = this.$route.params.id
或
id = this.$route.query.id