微信小程序错误e.showError is not a function. (In ‘e.showError(a.data.message)‘, ‘e.showError‘

错误样例: e.showError is not a function. (In ‘e.showError(a.data.message)’, ‘e.showError’ is undefined)

问题出在this.showError函数,这个wx.request是复制其它页面过来的,其中自定义showError函数没有随着一起复制过来,所以会报错。

checkMoney: function(){
//检测money是否>0,如果>0则跳转到花费活动页面。
wx.request({
url: app.globalData.host + ‘user/info/get’,
data: {
token: app.globalData.token
},
header: {
‘content-type’: ‘application/json’
},
method: ‘POST’,
dataType: ‘json’,
responseType: ‘text’,
success: (result) => {
if (result.data.code == 200) {
this.setData({
money: result.data.user_info.money
})
if(this.data.money>0){
if(app.globalData.getmoney == true){
wx.navigateTo({
url: ‘/pages/phonecash/phonecash’,
})
app.globalData.getmoney = false
console.log(app.globalData.getmoney)
}
}
} else {
this.showError(result.data.message);
}
},
fail: () => {
this.showError(“网络错误”);
},
complete: () => {} });

现在对此进行修改,首先是添加ShowError函数:

showError(msg) {
wx.showToast({
title: msg,
icon: ‘none’,
duration: 1500,
mask: false
});
},

然后更改checkMoney的触发条件,让有token的用户才能触发:

if(app.globalData.token!=’’) this.checkMoney();

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值