当前位置:网站首页>微信小程序页面跳转传参
微信小程序页面跳转传参
2022-08-05 05:19:00 【CrazyQiQi】
首先小程序页面跳转能够传递参数的API有
- wx.navigateTo()
保留当前页面,跳转到应用内的某个页面。但是不能跳到 tabbar 页面 - wx.reLaunchTo()
关闭所有页面,打开到应用内的某个页面 - wx.redirectTo()
关闭当前页面,跳转到应用内的某个页面。但是不允许跳转到 tabbar 页面。
在用wx.navigateTo()进行跳转是,需要将json对象的数据转化为字符串的形式
我们需要通过这两个函数将json数组进行类似于打包解包的过程。
JSON.stringify();//将json转成字符串传值
JSON.parse();//将字符串转成对象接收
这是我们跨页面传递的json数组
var json = [
{
"gender": "性别",
"weight": "重量"
}
]
接下来就是通过路径带参数,将参数转化为字符串格式,传递到目标页面
wx.navigateTo({
//url填写你要跳转的页面
url: './../index/index?json=' + JSON.stringify(json) //将json数组转化为字符串
同时传递过去后,我们需要在目标页将传递过来的参数拿出来
/** * 生命周期函数--监听页面加载 */
onLoad: function (options) {
var list = JSON.parse(options.json) //第一页传过来的字符串转化为json数组
console.log(list)
边栏推荐
猜你喜欢

阿里云视频点播

【Day8】Knowledge about disk and disk partition

静态路由
![[Paper Intensive Reading] The relationship between Precision-Recall and ROC curves](/img/8f/3c9944db96eef623779a5abe68355b.png)
[Paper Intensive Reading] The relationship between Precision-Recall and ROC curves

Getting Started Documentation 10 Resource Mapping

传输层协议(TCP3次握手)

云游戏未来展望
![[Day8] (Super detailed steps) Use LVM to expand capacity](/img/ff/d4f06d8b30148496da64360268cf1b.png)
[Day8] (Super detailed steps) Use LVM to expand capacity

Remembering my first CCF-A conference paper | After six rejections, my paper is finally accepted, yay!

什么?CDN缓存加速只适用于加速静态内容?
随机推荐
Account and Permission Management
Dsf5.0 bounced points determine not return a value
One-arm routing and 30% switch
The spark operator - repartition operator
云计算——osi七层与TCP\IP协议
成功的独立开发者应对失败&冒名顶替综
Getting Started 11 Automatically add version numbers
Getting Started Documentation 12 webserve + Hot Updates
【Day8】Knowledge about disk and disk partition
入门文档01 series按顺序执行
游戏引擎除了开发游戏还能做什么?
VLAN details and experiments
I/O性能与可靠性
IJCAI 2022|Boundary-Guided Camouflage Object Detection Model BGNet
云游戏未来展望
spark源码-任务提交流程之-7-流程梳理总结
硬核!Cocos开发面试必备十问,让你offer拿到手软
D41_缓冲池
网络布线与数制转换
通过单总线调用ds18b20的问题