V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
iyaozhen
V2EX  ›  问与答

weixin js SDK chooseImage 后马上调用 uploadImage 出错,有谁遇到过吗?

  •  1
     
  •   iyaozhen · Apr 27, 2015 · 5860 views
    This topic created in 4022 days ago, the information mentioned may be changed or developed.

    RT,weixin js chooseImage 后马上调用 uploadImage 非常容易出错。具体表现无反应,感觉 uploadImage 操作未执行一样。localIds 能正确获取,我 settimeout 1s uploadImage 会执行,成功率较高。

    wx.chooseImage({
        success: function (res) {
            wx.uploadImage({
                  localId: res.localIds[0],
                  success: function (res) {
                      alert(JSON.stringify(res));
                  },
                  fail: function (res) {
                      alert(JSON.stringify(res));
                  }
            });
        }
    });
    
    2 replies    2015-04-28 13:39:00 +08:00
    abccoder
        1
    abccoder  
       Apr 27, 2015   ❤️ 1
    这貌似是android版本微信下面的bug,在ios版本下面直接调用是没有任何问题的。我在这里的解决办法是直接timeout 1ms。
    android 微信(非google play版本)是采用的qq x5 的浏览器内核和ios微信及google play版微信的内置浏览器行为是有部分差别的,换句话说就是有坑,当心!
    iyaozhen
        2
    iyaozhen  
    OP
       Apr 28, 2015
    @abccoder 原来如此,我解决方法是设置的是timeout 1s。
    原来微信还有google play版本之分,受教了。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2123 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 00:34 · PVG 08:34 · LAX 17:34 · JFK 20:34
    ♥ Do have faith in what you're doing.