我创建了一个ReactJS组件,用于在数据表的每一行中显示编辑/删除按钮。
这是我的组成部分:
import React from 'react';
const iconStyle = {
border:'none',
boxShadow:'none',
backgroundColor:'transparent',
cursor:'pointer'
};
const RowEditButtons = (props) => {
const editButton = props.onEdit ?
<button type="button" className="btn btn-sm btn-secondary" onClick={props.onEdit.bind(null,props.index)} style={iconStyle}>
<img src="img/icon-pencil.svg" />
</button>
: null;
const deleteButton = props.onDelete ?
<button type="button" className="btn btn-sm btn-secondary" onClick={props.onDelete.bind(null,props.index)} style={iconStyle}>
<img src="img/close-o.svg" />
</button>
: null;
return (
<div className="btn-group" role="group" aria-label="Edit buttons" >
{editButton}
{deleteButton}
</div>
);
};
RowEditButtons.propTypes = {
index: React.PropTypes.number,
onEdit: React.PropTypes.func,
onDelete: React.PropTypes.func
};
export default RowEditButtons;
我在IE上测试(因为那是公司的标准),我注意到有时候按钮出现了,有时它们不会出现。有时它们会显示在某些行而不是其他行。它并不一致。在使用开发工具查看渲染的DOM之后,我看到按钮和图像在那里,只有图像的宽度=&#34; 0&#34;和height =&#34; 0&#34;。我不确定这里发生了什么,如果它是浏览器,反应器或引导程序。
有人有线索吗?