react ifame自适应高度
Others 2019-07-15 02:21:03 2019-07-15 02:21:03 2533 次浏览import React from 'react'; import ReactDOM from 'react-dom'; import { Row, Col, Icon, Button, Layout, Menu, Card } from 'antd'; export default class Iframe extends React.Component { constructor() { super(); this.state = { iFrameHeight: '0px' } } render() { return ( <iframe title="key" style={{width:'100%', height:this.state.iFrameHeight, overflow:'visible'}} onLoad={() => { const obj = ReactDOM.findDOMNode(this); this.setState({ "iFrameHeight": obj.contentWindow.document.body.scrollHeight + 'px' }); }} ref="iframe" src="/api/dealerList/info?sysDealerId=37009" width="100%" height={this.state.iFrameHeight} scrolling="no" frameBorder="0" /> ); } }
Links: 373