- 云函数本地调试,抛错后调试器log:-404006,不显示错误内容?
在开发工具中进行云函数的本地调试,调用云函数后,云函数throw error后,例如throw new Error('connect fail: ' + error.message);,调试器无法打印错误内容,cloud.callFunction的catch块不能捕获并输出具体错误,只显示 Error: cloud.callFunction:fail -404006 empty poll result base resp. at R (<anonymous>:1:234885) at <anonymous>:1:266826
05-01 - wx.request访问学信网出现状态码412,之前能访问现在不能?
https://www.chsi.com.cn/xlcx/bgcx.jsp wx.request({ // post方法 // url: 'https://yiyan.baidu.com/', url: 'https://www.chsi.com.cn/xlcx/bgcx.jsp', method: 'GET', success: (res)=>{ console.log(res); }, fail: (res)=>{ console.log(res); } }) GET https://www.chsi.com.cn/xlcx/bgcx.jsp 412 (Precondition Failed) (env: Windows,mp,1.06.2402021; lib: 3.0.2) [图片]
03-28 - 开发工具调试wx.requirePrivacyAuthorize报错后才能弹出官方隐私弹窗?
Page({ onLoad(){ // 取消该部分注释后,开发工具调试无报错,但不能弹出官方隐私弹窗 // if (wx.onNeedPrivacyAuthorization) { // wx.onNeedPrivacyAuthorization(resolve => { // // 需要用户同意隐私授权时 // // 弹出开发者自定义的隐私授权弹窗 // console.log(123); // this.setData({ // showPrivacy: true // }) // this.resolvePrivacyAuthorization = resolve // console.log(resolve); // }) // } wx.requirePrivacyAuthorize({ success: (res) => { // 用户同意授权继续小程序逻辑 wx.showToast({ title: '完成授权', }) }, fail: (e) => {console.log(e);}, // 用户拒绝授权 complete: () => {} }); }, }) [system] WeChatLib: 3.0.2 (2023.12.27 23:35:33) 开发工具调试报错如下: VM79560:1 invalid init scl: init before tap Error: invalid init scl: init before tap at Object.H [as initScl] (<anonymous>:1:260573) at Object.<anonymous> (http://127.0.0.1:42960/appservice/__dev__/WAServiceMainContext.js?t=wechat&s=1705554586761&v=3.0.2:1:2044301) at QN (http://127.0.0.1:42960/appservice/__dev__/WAServiceMainContext.js?t=wechat&s=1705554586761&v=3.0.2:1:967869) at http://127.0.0.1:42960/appservice/__dev__/WAServiceMainContext.js?t=wechat&s=1705554586761&v=3.0.2:1:635637 at new Promise (<anonymous>) at http://127.0.0.1:42960/appservice/__dev__/WAServiceMainContext.js?t=wechat&s=1705554586761&v=3.0.2:1:635616 at tB (http://127.0.0.1:42960/appservice/__dev__/WAServiceMainContext.js?t=wechat&s=1705554586761&v=3.0.2:1:968623) at http://127.0.0.1:42960/appservice/__dev__/WAServiceMainContext.js?t=wechat&s=1705554586761&v=3.0.2:1:1232131 at Generator.next (<anonymous>) at n (http://127.0.0.1:42960/appservice/__dev__/WAServiceMainContext.js?t=wechat&s=1705554586761&v=3.0.2:1:3663)(env: Windows,mp,1.06.2310080; lib: 3.0.2)
01-21 - 在云函数中通过axios访问code2session时拿不到session_key?
云函数中axios访问code2session,在本地云函数调试的Appdata中可以看到网络返回的session_key,但是无法控制台打印,也不能写入数据库 // 云函数入口文件 const cloud = require('wx-server-sdk') const axios = require('axios') cloud.init({ env: "指定云环境"}) // 使用当前云环境 const db = cloud.database() // 云函数入口函数 exports.main = async (event, context) => { const wxContext = cloud.getWXContext() console.log(wxContext); axios({ method: 'get', url: 'https://api.weixin.qq.com/sns/jscode2session', params: { appid: wxContext.APPID, secret: '自己的secret', js_code: event.code, //此处采用login获取的code grant_type: "authorization_code", } }) .then((response)=> { console.log(response) const userInfo = db.collection("usersBasicInfo").add({ data:{ openid: response["openid"], session_key: response["session_key"], unionid: response["unionid"] } }) return response //返回值为undefined }); } //callFunction后打印响应值{errMsg: "cloud.callFunction:ok", result: null, requestID: "一串字符"}
01-03 - 如何解决全局skyline引擎下,按钮点击无效,控制台无输出?
wxml <view class="container"> <image class="logo" src="../../assets/liudaxq.png" mode="aspectFit"></image> <button class="logon" bindtap="onLogonOrRegister">登录</button> </view> wxss /* pages/u_login/login.wxss */ .container { display: flex; flex-direction: column; position: relative; width: 100%; height: 100%; background-color: #323335; justify-content: space-around; align-items: center; } .logo { display: flex; box-sizing: border-box; position: relative; height: 10vh; width: 70%; justify-content: center; align-items: center; } .logon { display: flex; box-sizing: border-box; position: relative; width: 600rpx; height: 80rpx; justify-content: center; align-items: center; text-align: center; background-color: #3CAE89; border-radius: 50rpx; color: white; font-size: 36rpx; font-weight: bolder; } js /** * 登录按钮 */ onLogonOrRegister(){ console.log("登录") } [图片] [图片] [图片]
2023-12-05