天天看点

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

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中、参数传递以及重定向

2、页面重定向

关键部分代码

1、在路由中

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

2、返回首页

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

3、效果

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

继续阅读