# 读取图片宽高

/**
 * 读取网络图片的宽高
 *
 * @param {string} src - 图片url
 */
const getImgWH = src => {
  const img = new Image();
  img.src = src;
  img.onload = function() {
    console.log(this.width);
    console.log(this.height);
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
Last Updated: 4/27/2020, 10:56:04 PM