当前位置:网站首页>微信小程序获取当前页面的url和参数
微信小程序获取当前页面的url和参数
2022-08-11 00:10:00 【小任睡不醒`】
页面跳转添加参数
wx.navigateTo({
url: `../deeddetail/deeddetail?id=${e.currentTarget.dataset.id}`,
})接收options
1,在onLoad里接收参数
onLoad: function (options) {
console.log(options.id) //options.参数名就可以取到
},2,其他位置获取参数及url可以写成工具函数放到utils中:
/*获取当前页url*/
const getCurrentPageUrl=()=>{
let pages = getCurrentPages() //获取加载的页面
let currentPage = pages[pages.length-1] //获取当前页面的对象
let url = currentPage.route //当前页面url
return url
}
/*获取当前页参数*/
const getCurrentPageParam=()=>{
let pages = getCurrentPages() //获取加载的页面
let currentPage = pages[pages.length-1] //获取当前页面的对象
let options = currentPage.options //如果要获取url中所带的参数可以查看options
return options
}
module.exports = {
getCurrentPageUrl,
getCurrentPageParam
}3,使用
import utils from '../../../utils/util'
let url=utils.getCurrentPageUrl()
let options=utils.getCurrentPageParam()边栏推荐
- ASIO4ALL是什么
- 【pypdf2】安装、读取和保存、访问页面、获取文本、读写元数据、加密解密
- 7. yaml
- EN 12467纤维水泥平板产品—CE认证
- 线上突然查询变慢怎么核查
- ① 数据库介绍 及 关系型数据库的关系代数表达式
- web 性能提升(将持续更新……)
- Dump文件生成,内容,以及分析
- Why do programming languages have the concept of variable types?
- How to recover data from accidentally deleted U disk, how to recover deleted data from U disk
猜你喜欢

3d打印出现stl文件物体不是流形,意味着不是水密体...解决办法

SQL injection base

报错:Client does not support authentication protocol requested by server; consider upgrading MySQL cli

16. File upload

15. 拦截器-HandlerInterceptor

Web APIs BOM- 操作浏览器之综合案例

There is no recycle bin for deleted files on the computer desktop, what should I do if the deleted files on the desktop cannot be found in the recycle bin?

sqlmap combined with dnslog fast injection

编程语言为什么有变量类型这个概念?
![[C language] First understanding of pointers](/img/f2/3e28381212beabae85b832526808d2.png)
[C language] First understanding of pointers
随机推荐
[数据可视化] 图表设计原则
5. Lombok
EN 12467纤维水泥平板产品—CE认证
【redis】发布和订阅消息
How engineers treat open source
12. Handling JSON
复制带随机指针的链表——LeetCode
Design and Realization of Employment Management System in Colleges and Universities
[21天学习挑战赛——内核笔记](五)——devmem读写寄存器调试
How to do patent mining, the key is to find patent points, in fact, it is not too difficult
10. Notes on receiving parameters
Introduction to Qt (6) - Implementation of the lottery system
李彦宏拆墙交朋友,大厂“塑料友情”能否帮百度啃下硬骨头?
10. 接收参数相关注解
Three-column layout implementation
百战RHCE(第四十八战:运维工程师必会技-Ansible学习3-构建Ansible清单)
【pypdf2】安装、读取和保存、访问页面、获取文本、读写元数据、加密解密
虚拟电厂可视化大屏,深挖痛点精准减碳
2022下半年软考「高项」易混淆知识点汇总(2)
C language, operators of shift operators (> >, < <) explanation