当前位置:网站首页>使用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
});
边栏推荐
- 2022 safety officer-c certificate examination question simulation examination question bank and simulation examination
- jpa手写sql,用自定义实体类接收
- 2021 RoboCom 世界机器人开发者大赛-高职组复赛
- 软件架构的本质
- SWT / anr problem - SWT causes low memory killer (LMK)
- 神经网络物联网的发展趋势和未来方向
- 每日三题 6.30(2)
- Commemorate becoming the first dayus200 tripartite demo contributor
- Anomaly-Transformer (ICLR 2022 Spotlight)复现过程及问题
- 【无标题】
猜你喜欢
【必会】BM41 输出二叉树的右视图【中等+】
How to display real-time 2D map after rviz is opened
2022年R1快开门式压力容器操作考题及答案
从第三次技术革命看企业应用三大开发趋势
2022 crane driver (limited to bridge crane) examination questions and simulation examination
PostgreSQL source code (57) why is the performance gap so large in hot update?
Zero foundation tutorial of Internet of things development
Redis数据类型和应用场景
2022年危险化学品经营单位安全管理人员考试题及在线模拟考试
为什么PHP叫超文本预处理器
随机推荐
What are the common types of points mall games?
2022 crane driver (limited to bridge crane) examination questions and simulation examination
股票开户哪个证券公司最好,有安全保障吗
Who do you want to know when opening a stock account? Is it safe to open an account online?
Material Design组件 - 使用BottomSheet展现扩展内容(一)
ShanDong Multi-University Training #3
Aaai22 | structural tagging and interaction modeling: a "slim" network for graph classification
Current situation and future development trend of Internet of things
from pip._ internal. cli. main import main ModuleNotFoundError: No module named ‘pip‘
Linux基础 —— CentOS7 离线安装 MySQL
Distance measurement - Hamming distance
[understanding of opportunity-35]: Guiguzi - flying clamp - the art of remote connection, remote control and remote testing
Behind sharing e-commerce: the spirit of CO creation, symbiosis, sharing, CO prosperity and win-win
物联网应用技术专业是属于什么类
上海炒股开户选择手机办理安全吗?
How to display real-time 2D map after rviz is opened
Matplotlib common charts
[applet] realize the left and right [sliding] list through the scroll view component
Redis RDB快照
2022年最佳智能家居开源系统:Alexa、Home Assistant、HomeKit生态系统介绍