📜  在样式 jsx 中包含悬停 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:57.856000             🧑  作者: Mango

代码示例1
var Link = React.createClass({
  getInitialState: function(){
    return {hover: false}
  },
  toggleHover: function(){
    this.setState({hover: !this.state.hover})
  },
  render: function() {
    var linkStyle;
    if (this.state.hover) {
      linkStyle = {backgroundColor: 'red'}
    } else {
      linkStyle = {backgroundColor: 'blue'}
    }
    return(
      
    )
}