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

计算高度的bug

上级 63d087b7
......@@ -46,37 +46,26 @@ export default class Detail extends Component {
}
componentDidMount() {
// window.addEventListener(
// 'message',
// (event) => {
// if (event.data && event.data.indexOf && event.data.indexOf('iframeDetailHeight') > -1) {
// const height = Number(event.data.split('-')[1]);
// document.getElementById('detailIframeId').height = height;
// }
// },
// false,
// );
}
// showAll = () => {
// this.setState({
// showAll: true,
// });
// };
setIframeHeight = () => {
let iframe = document.getElementById('applyIframeId');
window.addEventListener(
'message',
(event) => {
if (event && event.data && event.data.indexOf && event.data.indexOf('iframeDetailHeight') > -1) {
let height = Number(event.data.split('-')[1]);
console.log(height);
const iframe = document.getElementById('applyIframeId');
if (iframe) {
let iframeWin = iframe.contentWindow || iframe.contentDocument.parentWindow;
if (iframeWin.document.body) {
iframe.style.height = (iframeWin.document.documentElement.scrollHeight || iframeWin.document.body.scrollHeight) + 'px';
iframe.height = height;
}
}
};
},
false,
);
}
render() {
const { id } = this.state;
let iframeUrl = `${config.gateWayPort}/portal/#/showSmartFormOnly?id=${id}&token=${getToken()}&isShow=true`;
iframeUrl = `http://localhost:8022/portal/#/showSmartFormOnly?id=${id}&token=${getToken()}&isShow=true`;
return (
<PageHeaderWrapper title="">
<Shell>
......@@ -84,16 +73,16 @@ export default class Detail extends Component {
src={iframeUrl}
frameBorder={0}
id="applyIframeId"
onLoad={this.setIframeHeight}
name="applyIframe"
marginWidth="0"
marginHeight="0"
allowtransparency="yes"
seamless
height={800}
scrolling={'no'}
style={{
width: '100%',
height: '800px',
// height: '800px',
overflowY: 'auto',
backgroundColor: '#fff',
}}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论