当前位置:网站首页>Uni app through uni Navigateto failed to pass parameter (pass object)
Uni app through uni Navigateto failed to pass parameter (pass object)
2022-06-25 19:48:00 【We are all lemonade】
Use navigateTo() This method is passed to the object , Print the transfer parameters in the page you jump to , You will find that the data you get is not what you want . Such as :
1、 Jump
// details
myInInfoClick(obj) {
// this.dataItem = obj;
uni.navigateTo({
url: './components/addIn?dataItem='+obj
});
},
2、 obtain
// onLoad Indicates that the listening page is loaded , Its parameter is the data passed from the previous page
onLoad(option) {
console.log(option);
}
3、 Print 
4、 reason
url Reference time , Do not convert data and when parameters have special characters , Will be intercepted , As a result, the data is incomplete . therefore , I want to solve this problem , Need to use encodeURIComponent Decode the data .
5、 terms of settlement
Be careful : Use encodeURIComponent When coding , Special characters of parameters need to be converted , Translates into string type .
(1) code
uni.navigateTo({
// obj Contains special characters Use JSON.stringify() Convert special characters And use encodeURlComponent() Encoding Browser can read
url:'./components/addIn?dataItem='+encodeURlComponent(JSON.stringify(obj))
});
(2) decode
summary :
First put the data JSON.stringify turn string Format , Reuse encodeURIComponent To convert special characters of data . Jump to the page , Use decodeURIComponent Turn back special characters , Reuse JSON.parse Convert to object format .
边栏推荐
- PHP FPM, workman, spoole, golang simple performance test
- wooyun-2014-065513
- shell-跳出循环-shift参数左移-函数的使用
- Automatic fitting when the applet reaches the top
- Tiger Dao VC products are officially launched, a powerful supplement to seektiger ecology
- User management and permissions
- MySQL transaction explanation
- 2、 Hikaricp source code analysis of connection acquisition process II
- MySQL prompt performance_ Schema missing table
- R language plot visualization: plot visualization of two-dimensional histogram contour (basic 2D histogram contour)
猜你喜欢

QQ机器人疫情查询/疫情关注等【最新beta2版本】

Tiger Dao VC products are officially launched, a powerful supplement to seektiger ecology

Kotlin Compose 终结toDo项目 点击可以编辑修改todo

Process of vacuum and vacuum full

Panda weekly -2022/02/18

Google cloud SSH enable root password login

SEO outsourcing reliable company, enterprise SEO outsourcing company which reliable?

Determine whether it is a web page opened on wechat

Vulnhub range - darkhole 1

谈谈CNN中的位置和尺度问题
随机推荐
Does GoogleSEO need to change the friend chain? (e6zzseo)
最新数据挖掘赛事方案梳理!
SQL is used for field data types in various databases
云上弹性高性能计算,支持生命科学产业高速发展、降本增效
Jsonp processing non homologous
rmi-registry-bind-deserialization
R language uses the model of DALEX package_ The profile function interprets the relationship between a continuous feature and the target value Y in multiple classification models based on the conditio
Convert word to PDF through libreoffice
JS get the parameters in the URL link
Laravel validation rule followed Role of auth:: id()
Guangzhou Sinovel interactive VR panorama brings development to all walks of life
三、HikariCP获取连接流程源码分析三
Many varieties of EA can be used
PostgreSQL change table owner
JS mobile phone and computer open different websites
QQ机器人疫情查询/疫情关注等【最新beta2版本】
MySQL transaction explanation
【历史上的今天】6 月 25 日:笔记本之父诞生;Windows 98 发布;通用产品代码首次商用
Applet password input box
Jsonp function encapsulation