import React, {Component} from 'react';
import logo from './logo.svg';
import './App.css';
import {Person,Twoway} from './Person/Person'
class App extends Component{
state={
showpink:false,
}
}
render(){
const style={
background: ''
}
const classes='class1'
//三目运算符控制按钮的颜色
{
this.state.showpink? style.background='pink': style.background= 'green'
}
);
return(
<div className="App">
<button style={style} onClick={this.add} className={classes}>添加</button>
</div>
)
}
}
export default App;
React-动态更改样式
猜你喜欢
转载自blog.csdn.net/Candy_mi/article/details/91350472
今日推荐
周排行