如何将wx.openSetting的结果return给调用方?
发布于 5 年前 作者 mluo 13583 次浏览 来自 问答

openSetting: async function () {

    return await wx.openSetting({

      withSubscriptions: true

    }).then(res=>{

      return res

    }).catch(err=>{

      return err

    })

  },

这种写法会发生“TypeError: Cannot read property ‘then’ of undefined”错误

查了一下,说wx.openSetting不接受Promise写法,那如何将返回数据return

给调用方?

2 回复

我们可以自己封装一个 Promise

可以用回调函数

openSetting: function (cb{
  wx.openSetting({
    success (res) {
      cb(res)
    }
  })
 }
回到顶部