Firefox表问题,使用反应和引导(Firefox table issue, use react and bootstrap)

编程入门 行业动态 更新时间:2024-10-08 18:40:31
Firefox表问题,使用反应和引导(Firefox table issue, use react and bootstrap)

我举了一个简单的例子

JSFiddle ←点击这里

JSX

class Test extends React.Component { constructor(props) { super(props); this.state = { isDropdownNow: false }; this.handleClick = this.handleClick.bind(this); } handleClick() { this.setState(prevState => ({ isDropdownNow: !prevState.isDropdownNow })); } render() { if (!this.props.data) { return null; } let _this = this; let keyData = this.props.data.filter(x => x > 5); let filteredData = this.state.isDropdownNow ? this.props.data : keyData; const rowList = filteredData.map(function (element, i) { return <tr key={i}><td>{element}</td></tr>; }); let buttonText = this.state.isDropdownNow ? 'Show Less' : 'Show More'; let dropDownButton = ( <tr style={{ height: '45px' }}> <td colSpan='2'> <button type="button" className="btn btn-link" style={{ width: '100%', fontWeight: 'bold' }} onClick={this.handleClick}>{buttonText}</button> </td> </tr> ); return <div ref='root'> <div className='osce-body-row'> <table className='table tableTest'> <tbody> {rowList} {dropDownButton} </tbody> </table> </div> </div>; } } ReactDOM.render(<Test data={[1,2,3,4,5,6,7,8,9,10]} />, document.querySelector("#root"))

这在Chrome中正常工作,并且添加-ms-grid在IE中按预期工作

在Firefox中显示更多按钮将永远增加高度,我不明白。 这是一个React问题还是一个网格问题或引导问题?

I made an simple example

JSFiddle ←Click here

jsx

class Test extends React.Component { constructor(props) { super(props); this.state = { isDropdownNow: false }; this.handleClick = this.handleClick.bind(this); } handleClick() { this.setState(prevState => ({ isDropdownNow: !prevState.isDropdownNow })); } render() { if (!this.props.data) { return null; } let _this = this; let keyData = this.props.data.filter(x => x > 5); let filteredData = this.state.isDropdownNow ? this.props.data : keyData; const rowList = filteredData.map(function (element, i) { return <tr key={i}><td>{element}</td></tr>; }); let buttonText = this.state.isDropdownNow ? 'Show Less' : 'Show More'; let dropDownButton = ( <tr style={{ height: '45px' }}> <td colSpan='2'> <button type="button" className="btn btn-link" style={{ width: '100%', fontWeight: 'bold' }} onClick={this.handleClick}>{buttonText}</button> </td> </tr> ); return <div ref='root'> <div className='osce-body-row'> <table className='table tableTest'> <tbody> {rowList} {dropDownButton} </tbody> </table> </div> </div>; } } ReactDOM.render(<Test data={[1,2,3,4,5,6,7,8,9,10]} />, document.querySelector("#root"))

This works fine in Chrome and adding -ms-grid works as expected in IE

In Firefox press show more button will always increase the height, I don't understand. Is this a React issue or a grid issue or a bootstrap issue?

最满意答案

这是一个与CSS的Firefox问题。 它与display: grid和margin 。 该错误已经被报告,但仍未得到证实。 https://bugzilla.mozilla.org/show_bug.cgi?id=1427148

This is a Firefox problem with css. It has something to do with display: grid and margin. The bug is already reported, but still unconfirmed. https://bugzilla.mozilla.org/show_bug.cgi?id=1427148

更多推荐

本文发布于:2023-07-27 08:25:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1287699.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:table   Firefox   issue   bootstrap   react

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!