当前位置:网站首页>使用uni-simple-router,动态传参 TypeError: Cannot convert undefined or null to object
使用uni-simple-router,动态传参 TypeError: Cannot convert undefined or null to object
2022-07-01 23:22:00 【itwangyang520】

之前的代码:
this.$Router.push({
path: `/pages/workbench/index/index`,
query: {
list: list,
data_url: list.data_url
}
})
}
修改后的代码:
/* 注意:使用router是有坑的,你可以使用两种方式解决这个问题: 1. 你可以在query里面使用encodeURIComponent(JSON.stringify(list))去传参 2. 你可以使用vuex去传参,也是可以实现动态的去传参 this.$store.commit('xxx', list) */
this.$Router.push({
path: `/pages/workbench/index/index`,
query: {
list: encodeURIComponent(JSON.stringify(list)),
data_url: list.data_url
}
})
我这里是加的encodeURIComponent(JSON.stringify(list)),
接收的数据
/* 注意:使用router是有坑的,你可以使用两种方式解决这个问题: 1. 方案一(推荐):你可以在query里面使用encodeURIComponent(JSON.stringify(list))去传参 2. 方案二:你可以使用vuex去传参,也是可以实现动态的去传参 this.$store.commit('xxx', list) */
// 方案二
// console.log(this.$store.state.limit)
// this.name = this.$store.state.limit.name == 'undefined' ? this.$store.state.limit.url : this.$store.state.limit.name
// this.data_url = this.$Route.query.data_url
// uni.setNavigationBarTitle({
// title: this.$store.state.limit.title
// });
// 方案一
this.name = this.$Route.query.list.name == 'undefined' ? this.$Route.query.list.url : this.$Route.query.list.name
this.data_url = this.$Route.query.data_url
uni.setNavigationBarTitle({
title: this.$Route.query.list.title
});
边栏推荐
- Postgresql随手记(10)动态执行EXECUTING语法解析过程
- 有没有一段代码,让你为人类的智慧所折服
- Practical application and extension of plain framework
- 物联网技术应用属于什么专业分类
- What are the common types of points mall games?
- Matplotlib common charts
- 13 MySQL-约束
- SWT / anr problem - SWT causes kernel fuse deadlock
- What professional classification does the application of Internet of things technology belong to
- 软件架构的本质
猜你喜欢

从第三次技术革命看企业应用三大开发趋势

物联网现状及未来发展趋势

2022年起重机司机(限桥式起重机)考试试题及模拟考试

Yoga27 multidimensional all-in-one computer with excellent appearance and high-end configuration

Matplotlib common charts

认识--Matplotlib

物联网开发零基础教程

2022 safety officer-c certificate examination question simulation examination question bank and simulation examination

ARP message header format and request flow

Win 10 mstsc connect RemoteApp
随机推荐
【小程序】通过scroll-view组件实现左右【滑动】列表
物联网现状及未来发展趋势
认识--Matplotlib
Material Design组件 - 使用BottomSheet展现扩展内容(一)
Stm32f030f4 drives tim1637 nixie tube chip
Aaai22 | structural tagging and interaction modeling: a "slim" network for graph classification
每日三题 6.30
Oracle中已定义者身份执行函数AUTHID DEFINER与Postgresql行为的异同
sql 优化
物联网开发零基础教程
从第三次技术革命看企业应用三大开发趋势
每日三题 6.29
The online beggar function of Japanese shopping websites
The best smart home open source system in 2022: introduction to Alexa, home assistant and homekit ecosystem
通过Go语言创建CA与签发证书
Matplotlib common charts
Glass mosaic
flutter Unable to load asset: assets/images/888. png
notBlank 和 notEmpty
ARP message header format and request flow