提交 4aa4f0a9 authored 作者: 钟是志's avatar 钟是志

21358 基础数据管理-床位管理,页面字段是否空可分配字段显示问题

上级 74559a6f
import React, { useState } from 'react';
export default function HandlePhoto({ urlObj, style, ...props}) {
let url = '';
try {
url = JSON.parse(urlObj).url;
} catch (e) {
url = urlObj;
}
const [needTransForm, setTransform] = useState(false);
if (url) {
const img = new Image();
img.src = url;
// 判断是否有缓存
if (img.complete) {
// 打印
if (img.width > img.height) {
setTransform(true);
}
console.log(img.width, img.height);
// alert('from:complete : width:'+img.width+',height:'+img.height)
} else {
// 加载完成执行
img.onload = () => {
if (img.width > img.height) {
setTransform(true);
}
};
}
}else{
return null;
}
let styleThis = {
...style,
transform : needTransForm ? 'rotate(-90deg)' : 'none',
}
return <img src={url} {...props} style={styleThis}/>
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论