在链接的时候直接传递消息,query--get明文传递,params--post加密传递,
但是注意 :to 使用vue的语法,需要绑定v-band
<router-link :to="{path:'/index',query:{un:'aaa',pw:'***'}}">OA入口</router-link>
<router-link :to="{name:'index',params:{un:'aaa',pw:'***'}}">OA入口</router-link>
接下来在index中接收参数首先看明文方式
参数是在路由中传递,参数需要过路由,所有用$接收,一个对象前习惯加一个$,代表当前vue路由对象中的一个实例
<template>
<h3>OA系统首页面</h3>
<hr/>
{{$route.query.un}},
{{$route.query.pw}}
<!-- {{$route.params.un}},
{{$route.params.pw}} -->
<router-link to ="/dept">部门管理</router-link> |
<router-link to ="/file">文档管理</router-link> |
<router-link to ="">邮箱管理</router-link>
<br/>
<router-view></router-view>
</template>
<script>
</script>
<style>
</style>
使用params加密传输时,在链接时需要把path改成name,因为要隐藏路径。
接收的时候使用params接收即可。
<template>
<h3>OA系统首页面</h3>
<hr/>
<!-- {{$route.query.un}},
{{$route.query.pw}}
-->
{{$route.params.un}},
{{$route.params.pw}}
<router-link to ="/dept">部门管理</router-link> |
<router-link to ="/file">文档管理</router-link> |
<router-link to ="">邮箱管理</router-link>
<br/>
<router-view></router-view>
</template>
<script>
</script>
<style>
</style>