实现按钮字体颜色切换
import React,{ useState } from 'react';
export default function Color() {
const [color, setColor] = useState('red');
const changeColor = () => {
setColor(color === 'red'?'blue':'red');
}
return (
<div>
<div>Color</div>
<div><button onClick={changeColor}>切换颜色</button></div>
<style jsx>
{`
div{
color:${color};
}
`}
</style>
</div>
)
}