-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
[js] 第61天 写一个方法获取图片的原始宽高 #256
Labels
js
JavaScript
Comments
|
除了 onload 和 append 还有其他方法吗 |
如果有用过七牛等云图片工具, 可以直接通过参数控制 |
补充一个知识点: |
function loadImageAsync(url) {
return new Promise(function(resolve, reject) {
var image = new Image();
image.onload = function() {
var obj = {
w: image.naturalWidth,
h: image.naturalHeight
}
resolve(obj);
};
image.onerror = function() {
reject(new Error('Could not load image at ' + url));
};
image.src = url;
});
} |
|
这两个api学习了,真不知道 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
第61天 写一个方法获取图片的原始宽高
The text was updated successfully, but these errors were encountered: