当前位置:网站首页>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 .
边栏推荐
- Install spoole
- Print 1 cute every 100 milliseconds ~ with a running lantern effect
- Mail monitoring cloud script execution progress
- 三、HikariCP获取连接流程源码分析三
- Cutting feet to fit shoes - talking about the ramp reconstruction on the track
- Divine reversion EA
- Read multiple associations from a field using delimiters in laravel
- Appearance of object attributes
- JVM | runtime data area (heap space)
- DARKHOLE 2
猜你喜欢
Applet password input box
Tiger Dao VC products are officially launched, a powerful supplement to seektiger ecology
Miner's Diary: why should I go mining on April 5, 2021
Can GoogleSEO only do content without external chain? (e6zzseo)
ECS 7-day practical training camp (Advanced route) -- day04 -- build a portal using ECs and polardb
mysql load data infile
PostgreSQL user role permissions
What are Baidu collection skills? 2022 Baidu article collection skills
Automatic fitting when the applet reaches the top
Vulnhub range - darkhole 1
随机推荐
Vulnhub range - the planes:venus
PHP Chinese regular
Apifox simple understanding -- the integrator of web side testing
QQ robot epidemic situation query / epidemic situation concern [latest beta2 version]
Processing method for uniapp or applet onload not receiving parameters
JQ implements tab switching
JS get the parameters in the URL link
通过启牛学堂开的股票账户可以用吗?资金安全吗?
3、 Hikaricp source code analysis of connection acquisition process III
Why are life science enterprises on the cloud in succession?
On Oracle full stack virtual machine -- graalvm
Network security detection and prevention test questions (V)
Server journey from scratch - Yu Zhongxian integrated version (IP access server, LNMP compilation and installation, Lua environment and socket expansion)
Ali visual AI training camp -day03- construction of electronic photo album (face and expression recognition)
三、HikariCP获取连接流程源码分析三
2、 Hikaricp source code analysis of connection acquisition process II
Applet password input box
Redis cache preheating & avalanche & breakdown & penetration
Google cloud SSH enable root password login
Google SEO external chain releases 50+ website platform sharing (e6zzseo)