前言
tabBar进入个人中心时,需要用户先授权再跳转页面,做的时候想着原生事件传递参数
问题描述
@getuserinfo=“userInfoAction” 当时想着如何传参数,默认不传递参数,定义方法时 userInfoAction(e) { // 这里是可以取到值的 }
尝试在 @getuserinfo=“userInfoAction(e, index, pagePath)” 传值,但失败
解决方法
<button class="phone" open-type="getUserInfo" @getuserinfo="userInfoAction($event, index, pagePath)">联系房东</button>
methods: {
userInfoAction(e, index, pagePath) {
console.log(e, index, pagePath) // 传递成功
}
}
微信小程序tabBar授权跳转
本文介绍在微信小程序中,如何在tabBar点击个人中心时,先进行用户授权再跳转页面的方法。通过在button组件上使用open-type='getUserInfo'及@getuserinfo事件,结合$event、index和pagePath参数,实现授权后页面跳转。
478

被折叠的 条评论
为什么被折叠?



