官方文档api例子错误
发布于 6 年前 作者 jinggu 19250 次浏览 来自 问答
// 可以通过 wx.getSetting 先查询一下用户是否授权了 "scope.record" 这个 scopewx.getSetting({

   success(res) {        

        if (!res['scope.record']) {

           wx.authorize({                scope: 'scope.record',                success() {                    // 用户已经同意小程序使用录音功能,后续调用 wx.startRecord 接口不会弹窗询问                    wx.startRecord()                }            })        }    } })

以上代码运行错误,res[‘scope.record’] undefined

正确运行代码:

wx.getSetting({

      success(res) {

        console.log(res);

        if (!res.authSetting[‘scope.userInfo’]) {

          gd.auths();

        } else {

          util.toPage(’…/chat/chat’);

        }

      }

    });

回到顶部