import React, { Component } from 'react'; import './index.less'; import Module from '../Module'; import Tabs from '../Tabs'; import Icon from '../Icon'; class QAItem extends Component { constructor(props) { super(props); this.Text = null; this.state = { show: false, more: false }; this.checkHeight(); } checkHeight() { if (this.Text != null) { console.log(this.Text.offsetHeight); if (this.Text.offsetHeight > 80) { this.setState({ more: true }); } } else { setTimeout(() => { this.checkHeight(); }, 1); } } render() { const { data } = this.props; const { show, more } = this.state; return (
Q: {data.content}
{ this.Text = ref; }} className="desc" > A: {data.answer}
{more && show && this.setState({ show: false })} />} {more && !show && this.setState({ show: true })} />}
); } } function QAList(props) { const { style, data = [], tabs = [], active } = props; return ( {tabs.length > 0 && } {data.map(item => { return ; })} ); } QAList.propTypes = {}; export default QAList;