vue 跳转页面传参的时候参数值为undefined的解决方法
生活随笔
收集整理的這篇文章主要介紹了
vue 跳转页面传参的时候参数值为undefined的解决方法
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
錯(cuò)誤代碼如下:
跳轉(zhuǎn)之前的頁面:
clickScan(index,row) {this.$router.push({path: '/biz/AssociationAcitvityEnroll',params: {associationId: row.associationId}})},跳轉(zhuǎn)之后的頁面
mounted: function () {this.associationId = this.$route.params.associationIdconsole.log(this.associationId) },我們會(huì)發(fā)現(xiàn)this.assocationId的值為undefined,原因是在跳轉(zhuǎn)之前沒有給name屬性的值,
正確的代碼如下:
跳轉(zhuǎn)之前的頁面:
clickScan(index,row) {this.$router.push({name: '社團(tuán)活動(dòng)',//這里必須有,沒有的話傳過去的值為undefinedpath: '/biz/AssociationAcitvityEnroll',params: {associationId: row.associationId}}) },name屬性值就是你在router文件夾下,index.js文件中配置路由中的name屬性
總結(jié)
以上是生活随笔為你收集整理的vue 跳转页面传参的时候参数值为undefined的解决方法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 使用element ui 组件的时候,如
- 下一篇: 数据结构-顺序查找算法的实现(C语言)