Vue中this.$router.push(参数) 实现页面跳转并接收参数
vue
vuejs/vue: 是一个用于构建用户界面的 JavaScript 框架,具有简洁的语法和丰富的组件库,可以用于开发单页面应用程序和多页面应用程序。
项目地址:https://gitcode.com/gh_mirrors/vu/vue
·
一 ,name跳转页面(命名路由跳转)
命名的路由 params传递的参数相当与发送了一次post请求,请求参数则不会显示,并且刷新页面之后参数会消失
传递参数(貌似是不能传递对象及数组类型):
this.$router.push({ name:'Login', params: { id: this.id } )
接收参数:
this.$route.params.id
二,path跳转页面
对象 query相当与发送了一次get请求,请求参数会显示在浏览器地址栏中
(1)不传递参数单纯跳转
this.$router.push('/task/index')
(2)传递字符串及其他非对象数据
this.$router.push({
path: '/task/index',
query: {
procInsId: record.procInsId,
deployId: record.deployId,
finished: true
}
})
接收参数:
this.$route.query && this.$route.query.deployId
(3)传递对象类型数据
传递当行所有数据record是一个对象{id:'',name:''}
this.$router.push({path: '/task/index',query:{...record}});
接收参数:
this.$route.query
注:this.$router.currentRoute.query知识点
router.currentRoute 相当于 $route
详情信息:

vuejs/vue: 是一个用于构建用户界面的 JavaScript 框架,具有简洁的语法和丰富的组件库,可以用于开发单页面应用程序和多页面应用程序。
最近提交(Master分支:4 个月前 )
9e887079
[skip ci] 1 年前
73486cb5
* chore: fix link broken
Signed-off-by: snoppy <michaleli@foxmail.com>
* Update packages/template-compiler/README.md [skip ci]
---------
Signed-off-by: snoppy <michaleli@foxmail.com>
Co-authored-by: Eduardo San Martin Morote <posva@users.noreply.github.com> 1 年前
AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。
更多推荐


所有评论(0)