当前位置:网站首页>微信小程序页面跳转传参
微信小程序页面跳转传参
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)
边栏推荐
- Getting Started Document 09 Standalone watch
- D41_缓冲池
- I217-V network disconnection problem in large traffic under openwrt soft routing
- 【Day8】(超详细步骤)使用LVM扩容
- Getting Started Document 07 Staged Output
- Configuration of TensorFlow ObjecDetectionAPI under Anaconda3 of win10 system
- Getting Started 03 Distinguish between development and production environments ("hot update" is performed only in the production environment)
- spark source code - task submission process - 1-sparkSubmit
- UE4美术你有必要了解的数学基础
- Servlet跳转到JSP页面,转发和重定向
猜你喜欢

虚幻引擎5都有哪些重要新功能?
![[Paper Intensive Reading] Rich Feature Hierarchies for Accurate Object Detection and Semantic Segmentation (R-CNN)](/img/a7/fc3fe440f5e57362d44ae875b7d436.png)
[Paper Intensive Reading] Rich Feature Hierarchies for Accurate Object Detection and Semantic Segmentation (R-CNN)

入门文档01 series按顺序执行

Wireshark抓包及常用过滤方法

Unity huatuo 革命性热更系列1.2 huatuo热更环境安装与示例项目

阿里云视频点播

Getting Started 04 When a task depends on another task, it needs to be executed in sequence

Three modes of vim

【Day1】VMware软件安装

Introductory document 05-2 use return instructions the current task has been completed
随机推荐
IP地址及子网的划分
添加新硬盘为什么扫描不上?如何解决?
lvm逻辑卷及磁盘配额
[Day1] (Super detailed steps) Build a soft RAID disk array
2020年手机上最好的25种免费游戏
spark算子-coalesce算子
如何使用Houdini进行程序化优化?
【Machine Learning】1 Univariate Linear Regression
VLAN details and experiments
【Day1】VMware软件安装
js动态获取屏幕宽高度
I217-V network disconnection problem in large traffic under openwrt soft routing
错误类型:reflection.ReflectionException: Could not set property ‘xxx‘ of ‘class ‘xxx‘ with value ‘xxx‘
单臂路由与三成交换机
NIO工作方式浅析
OpenCV3.0 is compatible with VS2010 and VS2013
【Day8】使用LVM扩容所涉及的命令
VRRP原理及命令
To TrueNAS PVE through hard disk
什么是阿里云·速成美站?