引用wx.getImageInfo方法
public getImageInfo(src): any {
return new Promise((resolve, reject) => {
wx.getImageInfo({
src: src,
success: (res) => {
resolve(res);
},
fail: (err) => {
reject(err);
}
});
});
}
方法返回的是Promise格式数组,需要提取数据
public draw(src) {
this.getImageInfo(src).then((res) => {
this.coverHeight = res.height;
this.coverWidth = res.width;
}).catch((err) => console.log(err));
}