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

图片插件有问题啊,图片和比例获取不到 #28

Open
yunposui opened this issue May 20, 2024 · 0 comments
Open

图片插件有问题啊,图片和比例获取不到 #28

yunposui opened this issue May 20, 2024 · 0 comments

Comments

@yunposui
Copy link

image | 图片对象
ratio | 图片实际的宽高与容器宽高的比例
这两个属性你挂载的时机有问题,应该是获取图片成功后挂载
但是源码中
function ImgPlugin(instance) {
// 图片对象
let image = null
// 最终渲染宽高与图片实际宽高的比例
let ratio = 0

instance.image = image
instance.ratio = ratio

}

function loadImage () {
utils.loadImage(opt.img)
.then((img) => {
image = img
imgActWidth = image.width
imgActHeight = image.height
init()
if (!isRefreshImage) {
_resolve()
}
})
.catch((e) => {
instance.observer.publish('IMG-LOAD-ERROR', e)
if (!isRefreshImage) {
_resolve()
}
})
}
你只是更新了保存的临时变量image ,并没有挂载到实例上去,希望确认下

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

1 participant