收藏
回答

jssdk在微信里 ios机型上用不了

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug sdk 微信iOS客户端 8.0.64 1.6.5

https://developers.weixin.qq.com/doc/service/guide/h5/adapt_ios.htmlhttps://developers.weixin.qq.com/doc/service/guide/h5/jssdk.html

async scanQRCodeWithWechatSDK() { // #ifdef H5 try { // 获取当前页面URL(用于签名) const currentUrl = window.location.href // 去掉hash部分 // 调用接口获取微信凭证 const signatureData = await post('/app/basicx/wechat/jssdk/signature', { url: currentUrl }) console.log('微信凭证:', signatureData) // 配置微信SDK wx.config({ debug: false, // 生产环境设为false appId: signatureData.appId, timestamp: signatureData.timestamp, nonceStr: signatureData.nonceStr, signature: signatureData.signature, jsApiList: ['scanQRCode'] // 需要使用的JS接口列表 }) // 配置完成后,调用扫码 wx.ready(() => { console.log('微信SDK配置成功,开始扫码') // 调用微信扫码接口 wx.scanQRCode({ needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果 scanType: ['qrCode', 'barCode'], // 可以指定扫二维码还是一维码,默认二者都有 success: (res) => { console.log('扫码成功:', res) const result = res.resultStr // 当needResult 为 1 时,扫码返回的结果 this.handleScanResult(result) }, fail: (err) => { console.error('扫码失败:', err) if (err.errMsg && err.errMsg.includes('cancel')) { // 用户取消扫码,不显示错误提示 return } uni.showToast({ title: '扫码失败,请重试', icon: 'none' }) } }) }) // 配置失败处理 wx.error((res) => { console.error('微信SDK配置失败:', res) uni.showToast({ title: '扫码配置失败,请重试', icon: 'none' }) }) } catch (error) { console.error('微信扫码异常:', error) uni.showToast({ title: '扫码失败,请重试', icon: 'none' }) } // #endif },
回答关注问题邀请回答
收藏

3 个回答

  • 社区技术运营专员--许涛
    社区技术运营专员--许涛
    2025-11-16

    你好,开发者工具打印下fail

    2025-11-16
    有用
    回复
  • 如意
    如意
    2025-11-14

    都是对 但是ios用不了 安卓可以

    2025-11-14
    有用
    回复
  • 智能回答 智能回答 本次回答由AI生成
    2025-11-14
    有用
登录 后发表内容