我正在使用React作为按钮。我希望它看起来不像一个按钮。有没有办法让它成为没有按钮外观的可点击div?这是我的代码:
<div style={styles.header}>
<Button.Group >
<Button onClick={this.refreshMyStuff}> Refresh </Button>
</Button.Group>
</div>
答案 0 :(得分:1)
您在这里:
class App extends React.Component {
constructor() {
super();
this.handleClick = this.handleClick.bind(this);
}
handleClick() {
console.log('clicked');
}
render() {
return (
<div className="button" onClick={this.handleClick}>Click me</div>
);
}
}
ReactDOM.render( <
App / > ,
document.getElementById('root')
);
.button {
border: 1px solid red;
width: 100px;
}
<script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script>
<div id="root" />