You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
510 B

2 years ago
  1. // jsx 样式控制
  2. // 1.行内样式:在元素身上绑定一个 style 属性即可
  3. // 2.类名样式:在元素身上绑定一个 className 属性即可
  4. import './App.css'
  5. const style = {
  6. fontSize: '30px',
  7. color: 'blue'
  8. }
  9. // 动态控制类名,满足条件才有
  10. var styleFlag = true
  11. function App() {
  12. return (
  13. <div className="APP">
  14. <span style={style}>6666666</span>
  15. <span className={styleFlag ? 'active' : ''}>测试类名样式</span>
  16. </div>
  17. );
  18. }
  19. export default App;