vue获取图片宽高
uploadFile(event){
let that = this;
let file = event.target.files[0];
let fileReader = new FileReader();
fileReader.readAsDataURL(file); //根据图片路径读取图片
fileReader.onload = function(e) {
let base64 = this.result;
let img = new Image();
img.src = base64;
img.onload = function() {
that.imgInfo = {
width: img.naturalWidth,
height: img.naturalHeight
};
console.log("宽:" + img.naturalWidth + " 高:" + img.naturalHeight);
}
}
},
- 上一篇 »用php或js获取图片大小,高宽尺寸
- 下一篇 »CSS + DIV 居中写法,不定宽高