vue 跳转路由传参数用法
// 组件 a
<template>
<button @click="sendParams">传递</button>
</template>
<script>
export default
{
name: '',
data () { return { msg: 'test message' } },
methods: {
sendParams () { this.$router.push({ path: 'yourPath', name: '要跳转的路径的 name,在 router 文件夹下的 index.js 文件内找', params: { name: 'name', dataObj: this.msg }
/*query: { name: 'name', dataObj: this.msg }*/ }) } },
computed: { }, mounted () { } }
</script>
<style scoped></style>
// 组件b
<template>
<h3>msg</h3>
</template>
<script>
export default {
name: '',
data () { return { msg: '' } },
methods: { getParams () {
// 取到路由带过来的参数
let routerParams = this.$route.params.dataobj
// 将数据放在当前组件的数据内
this.msg = routerParams } },
watch: {
// 监测路由变化,只要变化了就调用获取路由参数方法将数据存储本组件即可
'$route': 'getParams'
} }
</script>
<style scoped></style>
在mounted 生命周期函数中使用
mounted: function () {
this.$nextTick(function () {
this.getParams();
this.getSelectList();
if(this.id){
this.formItem.code=this.id;
this.fetchData();
}else{
this.fetchData();
}
})
},
vue 跳转路由传参数用法的更多相关文章
- react router @4 和 vue路由 详解(六)vue怎么通过路由传参?
完整版:https://www.cnblogs.com/yangyangxxb/p/10066650.html 8.vue怎么通过路由传参? a.通配符传参数 //在定义路由的时候 { path: ' ...
- vue 页面间使用路由传参数,刷新页面后获取不到参数的问题
情况 情况再简单说明一下: 有三个页面(a-列表页面,b-内页1,c-内页2),页面a->页面b->页面c有参数传递.从a进入b后,刷新b页面拿不到a页面传进来的参数.或者b页面再进入c页 ...
- 六、Vue-Router:基础路由处理、路由提取成单独文件、路由嵌套、路由传参数、路由高亮、html5的history使用
一.vue-router的安装 官网文档 [官网]:https://cn.vuejs.org/v2/guide/routing.html [router文档]:https://router.vuejs ...
- vue中的路由传参及跨组件传参
路由跳转 this.$router.push('/course'); this.$router.push({name: course}); this.$router.go(-1); this.$r ...
- vue跳转路由
1. router-link 1. 不带参数 <router-link :to="{name:'home'}"> <router-link :to=" ...
- React跳转路由传参3种方法和区别
1.params传参 路由表配置:参数地址栏显示 路由页面:<Route path='/demo/:id' component={Demo}></Route> //配置 /:i ...
- vue.js中路由传递参数
知识点:vue路由传递参数,第二个页面(A.B页面)拿到参数,使用参数 方法一:使用 <router-link :to="{name:'edithospital',params:{hi ...
- vue父子组件路由传参的方式
一.get方式(url传参): 1.动态路由传参: 父组件: selectItem (item) { this.$router.push({ path: `/recommend/${item.id}` ...
- vue路由的跳转-路由传参-cookies插件-axios插件-跨域问题-element-ui插件
---恢复内容开始--- 项目初始化 创建一个纯净的vue环境项目,手动书写全局的样式配置,全局的main,js配置 (1)如果vue项目在重构或者出错的时候,手动安装node_modules. 如果 ...
随机推荐
- OpenCV——图像的深度与通道数讲解
矩阵数据类型: – CV_(S|U|F)C S = 符号整型 U = 无符号整型 F = 浮点型 E.g.: CV_8UC1 是指一个8位无符号整型单通道矩阵, CV_32FC2是指一个32位浮点型双 ...
- 第三次作业:结对编程--实现表格在APP的导入和显示
031302517 031302319 ps:共同完成一篇随笔,文章中的第一人称我(517),队友(319) 一.功能分析+实现思路+结队讨论 这里我将功能分析和实现思路还有结对过程中的一些讨论结合在 ...
- 添加默认的过滤条件xml
<search string="Search Sales Origin"> <field name="name"/> <field ...
- boot.img的修改
个文件:boot.img.system.img.userdata.img.其中boot.img 存放着内核以及Android系统的配置信息,比如android系统各文件夹的读写权限,adb 的权限.所 ...
- 20155327 李百乾 Exp7 网络欺诈防范
20155327 李百乾 Exp7 网络欺诈防范 基础问题回答 (1)通常在什么场景下容易受到DNS spoof攻击 就此次试验来看,被收到NDSspoof攻击,首先要被攻击机扫描,并被设置为目标,所 ...
- 利用Github搭建自己的博客
教程链接:搭建个人博客 嘿嘿嘿!!一直想自己搭建博客的,一直没机会,这次终于把博客搭了起来.虽然只是一个壳子..套了别人的模板~不过还是很令人兴奋哟!总的来说,就按照这个教程一直往下走,其中有一个坑就 ...
- apache目录别名
#默认家目录DocumentRoot "/var/www/html"<Directory "/var/www"> AllowOverride Non ...
- Mybatis使用generator自动生成的Example类使用OR条件查询
参考:https://blog.csdn.net/qq_36614559/article/details/80354511 public List<AssetsDevicetypeRefacto ...
- 纯 CSS 利用 label + input 实现选项卡
clip 属性 用于剪裁绝对定位元素. .class { position:absolute; clip:rect(0px,60px,200px,0px); } scroll-behavior: sm ...
- effective c++ 笔记 (1-3)
// // effective c++.cpp // 笔记 // // Created by fam on 15/3/23. // // //-------------------------- ...