press-ui
Version:
简单、易用的跨端组件库,兼容 Vue2 和 Vue3,同时支持 uni-app和普通 Vue 项目
27 lines (24 loc) • 554 B
JavaScript
function getServiceAddress() {
return `${window.location.protocol}//${window.location.host}`;
}
export function getImageInfo({
src,
success,
}) {
const img = new Image();
const realPath = src;
img.onload = function () {
success({
errMsg: 'getImageInfo:ok',
width: img.naturalWidth,
height: img.naturalHeight,
path: realPath.indexOf('/') === 0 ? getServiceAddress() + realPath : realPath,
});
};
img.onerror = function () {
success({
errMsg: 'getImageInfo:fail',
});
};
img.src = src;
}