微信小程序采坑

1.tabBar跳转时无法带参数,解决方法:
//search.js
var app = getApp();
Page({
confirm: function(e){
//获取数据,添加到全局
let val = e.detail.value;
app.searchWord = val;
this.jump();
},
jump: function(){
//跳转tabBar
wx.switchTab({
url: ‘…/index/index’,
});
},
});

//index.js
var app = getApp();
Page({
onShow: function(e){
//获取全局数据
let val = app.searchWord;
}
});
//需要传递参数的页面在跳转前将数据添加到app.js里。需要接受参数的页面在onShow方法接受之前添加到app.js的数据。
2.wx.request()使用post方法请求时,还需要加上header,header[content-type]值为application/x-www-form-urlencoded。例:
wx.request({
url: ‘https://a.com/url.php’,
data: {message: 123},
method: ‘POST’,
header: {
‘content-type’: ‘application/x-www-form-urlencoded’
},
success: function(e){
console.log(e)
}
});
3.Do not have onCollectionTap handler in current page: pages/index/index-detail/index-detail. Please make sure that onCollectionTap handler has been defined in pages/index/index-detail/index-detail, or pages/index/index-detail/index-detail has been added into app.json报错
catchtap="onCollectionTap "
在问题出现前,已将该onCollectionTap事件在index-detail.js文件中定义了,同时也已将index-detail路径在app.json中配置了,
最后发现多了个空格。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值