get(){
this. getsttag(app.globalData.shitangname) ///查询选择的食堂是否关闭了当日报餐功能
if (app.globalData.sttag == '1') {
wx.showToast(
{
icon:'error',
title:'已关闭当日报餐',
})
return
}else
{console.log("打印测试获取的数据",'000000')}
}
这个get()在执行的时候,先if判断 后再执行this. getsttag(app.globalData.shitangname),
想要的是先this. getsttag(app.globalData.shitangname) 执行这个后得到结果app.globalData.sttag 的值,再if判断
帮忙看下怎么异步执行,谢谢
async get(){ const res = await this.getsttag(app.globalData.shitangname) console.log(res) // 具体你这个会返回啥不清楚,你下面的判断按照你的条件来 if (res.xxx) { if (app.globalData.sttag == '1') { return wx.showToast({ icon:'error', title:'已关闭当日报餐', }) } else { console.log("打印测试获取的数据",'000000') } } }