微信小程序实际开发问题总结

1丶微信小程序之文件下载并预览兼容ios出现的问题
下面展示一些 内联代码片
一开始调用wx.downloadFile下载文件获取微信的一个可访问的文件地址并通过 wx.openDocument打开生成的文件地址,在安卓中是能直接打开预览,在ios中需要加fileType,比如是word,fileType就是‘word’文件,下面示例是根据我实际业务场景获取到的文件类型,不加fileType在苹果中就没法打开。

  // 下载附件
  downFile(e){
    console.log(e);
    // console.log(e.currentTarget.dataset.id);
    wx.downloadFile({
      url: e.currentTarget.dataset.accessurlpath, //仅为示例,并非真实的资源
      success: function(res) {
        console.log(res)
        console.log(res.tempFilePath.split('.'));
        let fileArr = res.tempFilePath.split('.')
        wx.openDocument({
          fileType: e.currentTarget.dataset.type,
          filePath: res.tempFilePath,
          success(){
              // Toast('文件打开成功')
          }
      })
        // wx.playVoice({
        //   filePath: res.tempFilePath
        // })
      }
      })
  },
// An highlighted block
  // 下载附件
  downFile(e){
    console.log(e);
    // console.log(e.currentTarget.dataset.id);
    wx.downloadFile({
      url: e.currentTarget.dataset.accessurlpath, //当前文件的url
      success: function(res) {
        console.log(res)
        console.log(res.tempFilePath.split('.'));
        let fileArr = res.tempFilePath.split('.')
        wx.openDocument({
          fileType: e.currentTarget.dataset.type, // **此处为兼容ios无法打开预览的关键**
          filePath: res.tempFilePath,
          success(){
              // Toast('文件打开成功')
          }
      })
        // wx.playVoice({
        //   filePath: res.tempFilePath
        // })
      }
      })
  },

2丶当我作为微信开发者工具的开发用户选择真机调试让其他人扫码调试之后,由于其他人没有正确结束调试,导致下次再点真机调试生成的二维码一直显示已结束请重新开始,亲测有效解决方法
在这里插入图片描述
用扫码真机调试的人的微信号登录微信开发者工具再次进行真机调试就没问题了(当前我觉得前提应该是这个用户应该也需要是有权限参与当前微信小程序开发的)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值