import React, { Component, Fragment } from "react";
import './App.css'
class App extends Component {
constructor (props) {
super(props)
this.state = {
isShow: true
}
this.handleClickToggle = this.handleClickToggle.bind(this)
}
render () {
return (
<Fragment>
<div className={this.state.isShow ? "show": "hide"}>你好</div>
<button onClick={this.handleClickToggle}>隐藏/显示</button>
</Fragment>
)
}
handleClickToggle () {
this.setState({
isShow: this.state.isShow ? false: true
});
}
}
export default App;