赞
踩
- 参数在链接上显示
- this.$router.push({path: '/details', query: {id: 666}});
- this.$route.query.id;
-
- 参数不在链接上显示
- this.$router.push({ name: 'details', params: { userId: 123 }});
- {{this.$route.params.userId}};
-
- 注:采用params在必须要要在路由上配置name,否则undefined
- routes: [
- {
- path: '/details',
- name: 'details',
- component: resolve => require(['../components/details'], resolve)
- }
- ]
-
-
- <router-link :to="{name:'home', params: {id:1}}">
-
- $route.params.id // html 取参
- this.$route.params.id // script 取参
-
- params传参数 (类似post)
- 路由配置 path: "/home/:id" 或者 path: "/home:id"
- 不配置path ,第一次可请求,刷新页面id会消失
- 配置path,刷新页面id会保留
-
-
-
-
- <router-link :to="{name:'home', query: {id:1}}">
-
- $route.query.id // html 取参
-
- query传参数 (类似get,url后面会显示参数)
- 路由可不配置
-
-
-
this.$router.go(n)
向前或者向后跳转n个页面,n可为正整数或负整数。
如this.$router.go(-1)------->返回上一页
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。