当前位置:网站首页>使用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
});
边栏推荐
- Redis data types and application scenarios
- Li Kou today's question -241 Design priorities for operational expressions
- VIM color the catalogue
- Glass mosaic
- The third part of the construction of the defense system of offensive and defensive exercises is the establishment of a practical security system
- Wechat personal small store one click opening assistant applet development
- 2022 crane driver (limited to bridge crane) examination questions and simulation examination
- Win 10 mstsc connect RemoteApp
- Zhao Fuquan: to ensure supply in the short term, we should build a safe, efficient and resilient supply chain in the long term
- PostgreSQL source code (57) why is the performance gap so large in hot update?
猜你喜欢

Current situation and future development trend of Internet of things

CKS CKA ckad change terminal to remote desktop

ARP报文头部格式和请求流程

Commemorate becoming the first dayus200 tripartite demo contributor
![[understanding of opportunity-35]: Guiguzi - flying clamp - the art of remote connection, remote control and remote testing](/img/08/9ecfd53a04e147022dde3449aec132.png)
[understanding of opportunity-35]: Guiguzi - flying clamp - the art of remote connection, remote control and remote testing

CADD course learning (3) -- target drug interaction

Wechat personal small store one click opening assistant applet development

Matplotlib常用图表

Yunxin small class | common cognitive misunderstandings in IM and audio and video

学成在线案例实战
随机推荐
CADD course learning (3) -- target drug interaction
Know --matplotlib
Daily three questions 6.28
What is the mosaic tailgate?
Leetcode(34)——在排序数组中查找元素的第一个和最后一个位置
Who do you want to know when opening a stock account? Is it safe to open an account online?
Experience of practical learning of Silicon Valley products
Microservice stability management
De PIP. Interne. CLI. Main Import main modulenotfounderror: No module named 'PIP'
PostgreSQL source code (58) tuple splicing heap_ form_ Tuple analysis
Zhao Fuquan: to ensure supply in the short term, we should build a safe, efficient and resilient supply chain in the long term
Aaai22 | structural tagging and interaction modeling: a "slim" network for graph classification
Oracle中已定义者身份执行函数AUTHID DEFINER与Postgresql行为的异同
Daily three questions 6.30 (2)
物联网技术应用属于什么专业分类
Redis数据类型和应用场景
Linux基础 —— CentOS7 离线安装 MySQL
Paramètres communs de matplotlib
常见的积分商城游戏类型有哪些?
y53.第三章 Kubernetes从入门到精通 -- ingress(二六)