vue.js中路由传递参数
2024-10-17 08:25:38
知识点:vue路由传递参数,第二个页面(A.B页面)拿到参数,使用参数
方法一:使用 <router-link :to="{name:'edithospital',params:{hid:101}}">编辑</router-link>
1.在路由配置中添加
{
name:'edithospital', \\路由的名字
path: '/edithospital/:hid', \\路由中添加要传递的参数:hid
component: resolve => require(['../components/page/hospital/EditHospital.vue'], resolve)
}
. A页面
<router-link :to="{name:'edithospital',params:{hid:101}}">编辑</router-link> \\101是变量,可根据实际情况改变
\\name是路由的名字,params是传递的参数
3. B页面 <template><template>中添加
{{$route.params.hid}} // 101
方法二:<button @click="handleEdit(scope.$index, scope.row)"> 编辑</button>
1.同上
2.A页面
handleEdit(index, row) {
this.$router.push({
name: 'edithospital',
params: {
hid: row.hid //row.hid为变量
}
})
}, 3.同上
--------------------------------------------------------------------------------------------------------------------------------------
效果参考:
可参考:1.https://segmentfault.com/q/1010000009749320
2.http://blog.csdn.net/wy01272454/article/details/77869442?locationNum=7&fps=1
最新文章
- Android开发之Activity横竖屏切换生命周期重建问题
- ios CoreData NSManagedObject 生命周期
- Tomcat7 安装StartSSL证书笔记
- drupal里面的ajax最粗浅的理解-流程
- Yii 框架ajax搜索分页
- [Webpack 2] Grouping vendor files with the Webpack CommonsChunkPlugin
- Self-numbers 2 - SGU 108
- QDomDocument类
- 认识<;hr>;标签,添加水平横线
- iOS 准备
- Springmvc+Spring+Mybatis实现员工登录注册功能
- RedHat升级Python到2.7.6
- BZOJ 3123: [Sdoi2013]森林 [主席树启发式合并]
- Ubuntu 18.04 启动root账号并授权远程登录
- 【问题解决方案】AttributeError: module &#39;pygal&#39; has no attribute &#39;Worldmap&#39;
- 【Python 02】计算机与程序设计
- Python之进度条及π的计算
- fastjson序列化乱序问题
- js 在线引用
- Java 虚拟机 最易理解的 全面解析
热门文章
- mysql主从同步出现异常语句跳过错误处理
- Gunner II--hdu5233(map&;vector/二分)
- wait_event族函数浅析
- HTTP request is unauthorized with client authentication scheme &#39;Anonymous&#39;. The authentication header received from the server was &#39;NTLM&#39;。
- git本地与远程分支
- centos7配置IP地址
- 读取xml文件,写入excel
- PHP魔术方法和魔术常量介绍及使用
- UVA+POJ中大数实现的题目,持续更新(JAVA实现)
- docker——安装