Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

小程序端不能加载网络图片 #29

Open
houta-higuchi opened this issue Nov 16, 2020 · 2 comments
Open

小程序端不能加载网络图片 #29

houta-higuchi opened this issue Nov 16, 2020 · 2 comments

Comments

@houta-higuchi
Copy link

开发者工具可以,但安卓真机不行

//加载图片
    load: function () {
      var self = this;
      var src = this.data.src;

      wx.showLoading({
        title: '正在加载图片...',
      })
      
      wx.getImageInfo({
        src: src,
        success(res) {
          console.log("获取图片成功")
          self.originImage = res;
          self._orientation = self.orientationToNumber(res.orientation);
          self.getRealCotentSize();
          setTimeout(function () {
            var image = self.$cropContent.createImage();
           //开发者工具打印的是dom, 安卓真机打印的是空object
            console.log("image======", image);
            image.onerror =function (err) { console.log('image加载失败', err, image) }
            image.onload = function () {
              console.log("image onLoad")
              self.transformCoordinates(image);
              self.init();
            }
            image.src = src;
            
          }, 50) // ios delay 保证 canvas style 尺寸生效
        },
        fail(res) {
          console.log("获取图片失败", res)
        }
      })
    },
@newbieYoung
Copy link
Owner

@houta-higuchi 我自测是可以的哦

@newbieYoung
Copy link
Owner

@houta-higuchi createImage api 有版本要求,另外 getImageInfo api 处理网络图片时需要配置域名

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants