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

小程序无法加载本地图片 #12

Closed
hujian opened this issue Jun 26, 2018 · 1 comment
Closed

小程序无法加载本地图片 #12

hujian opened this issue Jun 26, 2018 · 1 comment

Comments

@hujian
Copy link

hujian commented Jun 26, 2018

如果在小程序使用下面的代码是无法加载本地图片的:

    const bitmap = new cax.Bitmap('./local.png', () => {

看了下util里面的代码,用判断是否是wxfile://开头来判断是否是网络图片,在小程序里面就走downloadfile了。

export function getImageInWx (img, callback) {
  if (img.indexOf('wxfile://') === 0) {
    wx.getImageInfo({
      src: img,
      success: (info) => {
        callback({
          img: img,
          width: info.width,
          height: info.height
        })
      }
    })

@dntzhang
Copy link
Owner

多谢~ @hujian

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