1、参数传递

关键部分代码
1、参数传递

  <router-link :to="{name:'information',params:{id:1}}">用户信息</router-link>

2、在路由中设置

{path:'/user/information/:id',name:'information',component:Information,props:true},

3、在页面获取传递的值

<template>
<div>
<h1>我是用户的详细信息</h1>
{{id}}
</div>
</template>

<script>
export default {
props:['id'],
name: "Information"
}
</script>

4、效果

Vue中、参数传递以及重定向_参数传递


Vue中、参数传递以及重定向_参数传递_02

2、页面重定向

关键部分代码

1、在路由中

Vue中、参数传递以及重定向_参数传递_03

2、返回首页

Vue中、参数传递以及重定向_前端_04


3、效果

Vue中、参数传递以及重定向_参数传递_05


点击返回

Vue中、参数传递以及重定向_用户信息_06