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

Taro.getImageInfo API 在 web( h5 ) 不能使用, 与文档不符 #3087

Closed
kid1412621 opened this issue May 18, 2019 · 7 comments
Closed

Taro.getImageInfo API 在 web( h5 ) 不能使用, 与文档不符 #3087

kid1412621 opened this issue May 18, 2019 · 7 comments
Assignees

Comments

@kid1412621
Copy link

问题描述
Taro.getImageInfo API 在 web( h5 ) 不能使用, 与 文档 不符。类似情况还有,请更新下文档,这样很浪费开发者时间啊。

复现步骤
web 环境调用 API

期望行为
文档和实际行为一致
image

报错信息
image

系统信息
Taro CLI 1.2.26 environment info:
System:
OS: Windows 10
Binaries:
Node: 12.2.0 - C:\Program Files\nodejs\node.EXE
npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD

补充信息

@taro-bot
Copy link

taro-bot bot commented May 18, 2019

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

@Littly
Copy link
Contributor

Littly commented May 18, 2019

升级到1.3.0-beta.2

@kid1412621
Copy link
Author

kid1412621 commented May 18, 2019

1.3.0-beta.2

nb 了,版本未发, 文档先行 , h5 报错:

Uncaught TypeError: Cannot read property 'isRoute' of undefined
    at findRef (index.js?56fb:212)
    at createCanvasContext (createCanvasContext.js?3cd4:10)
    at WrappedComponent.onGenPost (index.js?7a4d:86)
    at CourseItem.toGenPost (index.js?5998:30)
    at dispatchEvent (index.esm.js?eb37:508)
    at dispatchEvent (index.esm.js?eb37:518)
    at HTMLDocument.eventHandler (index.esm.js?eb37:546)

还有,请问下getImageInfo 在小程序端要获取本地图片应该怎么写呢? 我图片在 /asset/image/ 下, 但是微信那边报错, 路径前面加了 /pages/ 怎么破啊?

@Littly
Copy link
Contributor

Littly commented May 18, 2019

1.3.0-beta.2

nb 了,版本未发, 文档先行 , h5 报错:

Uncaught TypeError: Cannot read property 'isRoute' of undefined
    at findRef (index.js?56fb:212)
    at createCanvasContext (createCanvasContext.js?3cd4:10)
    at WrappedComponent.onGenPost (index.js?7a4d:86)
    at CourseItem.toGenPost (index.js?5998:30)
    at dispatchEvent (index.esm.js?eb37:508)
    at dispatchEvent (index.esm.js?eb37:518)
    at HTMLDocument.eventHandler (index.esm.js?eb37:546)

还有,请问下getImageInfo 在小程序端要获取本地图片应该怎么写呢? 我图片在 /asset/image/ 下, 但是微信那边报错, 路径前面加了 /pages/ 怎么破啊?

这个错貌似是因为你的cli没有一起升级导致的

你的getImageInfo是怎么调用的?

@Littly Littly self-assigned this May 18, 2019
@Littly Littly added the H5 API label May 18, 2019
@kid1412621
Copy link
Author

kid1412621 commented May 20, 2019

1.3.0-beta.2

nb 了,版本未发,文档先行,h5 报错:

Uncaught TypeError: Cannot read property 'isRoute' of undefined
    at findRef (index.js?56fb:212)
    at createCanvasContext (createCanvasContext.js?3cd4:10)
    at WrappedComponent.onGenPost (index.js?7a4d:86)
    at CourseItem.toGenPost (index.js?5998:30)
    at dispatchEvent (index.esm.js?eb37:508)
    at dispatchEvent (index.esm.js?eb37:518)
    at HTMLDocument.eventHandler (index.esm.js?eb37:546)

还有,请问下 getImageInfo 在小程序端要获取本地图片应该怎么写呢?我图片在 /asset/image/ 下,但是微信那边报错,路径前面加了 /pages/ 怎么破啊?

这个错貌似是因为你的 cli 没有一起升级导致的

你的 getImageInfo 是怎么调用的?

也升级了哈, Taro v1.3.0-beta.3

  Taro CLI 1.3.0-beta.3 environment info:
    System:
      OS: Windows 10
    Binaries:
      Node: 12.2.0 - C:\Program Files\nodejs\node.EXE
      npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD

调用:

 const ctx = Taro.createCanvasContext('post-canvas', this.$scope)
    Taro.getImageInfo({
      src: img.src,
    }).then(res => {
      ctx.drawImage(res.path, 0, 0, 750, 400, 750, 400)
      ctx.draw();
    })

@kid1412621
Copy link
Author

kid1412621 commented May 20, 2019

Taro.getImageInfo

嗯, 本地图片不用 Taro.getImageInfo 了吧? 我发现 drawImage 本地图片直接写相对路径又可以了, 神奇了


我知道了, 图片必须引用才会编译进 dist , 但我这个图片只是在画布中才用啊

@taro-bot
Copy link

taro-bot bot commented Jun 8, 2019

Hello~

您的问题楼上已经有了确切的回答,如果没有更多的问题这个 issue 将在 15 天后被自动关闭。

如果您在这 15 天中更新更多信息自动关闭的流程会自动取消,如有其他问题也可以发起新的 Issue。

Good luck and happy coding~

@taro-bot taro-bot bot removed the to be closed label Jun 10, 2019
@taro-bot taro-bot bot closed this as completed Jun 10, 2019
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