vue router

88 阅读1分钟

路由的query参数

!-- 跳转并携带query参数,to的字符串写法 -->
   <router-link :to="/home/message/detail?id=666&title=你好">跳转</router-link>
   				
   <!-- 跳转并携带query参数,to的对象写法 -->
   <router-link 
   	:to="{
   		path:'/home/message/detail',
   		query:{
   		   id:666,
               title:'你好'
   		}
   	}"
   >跳转</router-link>
复制代码

路由的params参数

{
path:'/home',
component:Home,
children:[
   	{path:'news',
   	component:News},
   	{component:Message,
        children:[{
        name:'xiangqing',
        path:'detail/:id/:title', //使用占位符声明接收params参数
        component:Detail}]}]}

\