微信小程序链接传参并跳转新页面

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

微信小程序链接传参并跳转新页面

XiaoBaiduQs   2020-05-15 我要评论

 像传统的传参一样,只是在微信里面的标签不一样而已,navigator标签的文档说明

https://mp.weixin.qq.comhttps://img.qb5200.com/download-x/debug/wxadochttps://img.qb5200.com/download-x/dev/component/navigator.html?t=20161122

下面是传递参数并展示新页面的一个简单栗子:

这是index.wxml代码:

<navigator class="bury-wrapper wx-li" url="..https://img.qb5200.com/download-x/detailhttps://img.qb5200.com/download-x/detail?id={{name.id}}"> 
<view>评19</view> 
</navigator>

url是..https://img.qb5200.com/download-x/detailhttps://img.qb5200.com/download-x/detail....... 传递参数是id="{{item.id}}" url="..https://img.qb5200.com/download-x/detailhttps://img.qb5200.com/download-x/detail?id=88"

detail.js代码如下

Page({ 
onLoad: function(options) { 
var duanziId = options.id 
var that = this 
wx.showToast({ 
title: '加载中', 
icon: 'loading', 
duration: 1000 
}) 
wx.request({ 
url: 'https://www.xxx.xxx?m=getDetail&duanziId='+duanziId, //服务器参数接收地址, 
data: {token:token}, 
method: 'GET', 
success: function(res){ 
console.log(res.data.result) //打印获取数据 
that.setData({ 
duanziDetail:res.data.result 
}) 
} 
}) 
} 
})

detail.wxml代码:

<view class="duanzi-content"> 
<text class="dz-content">{{duanziDetail.content}}</text> 
</view>

app.json中pages配置代码如下

"pages":[ 
"pages/index/index", 
"pageshttps://img.qb5200.com/download-x/detailhttps://img.qb5200.com/download-x/detail", 
"pages/center/center", 
"pages/tucao/tucao", 
"pages/search/search" 
]

目录结构:

以上所述是小编给大家介绍的微信小程序链接传参并跳转新页面,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们