使用style方式
import React, { useState } from 'react'
export default function Boke() {
const [isShow,setisShow] = useState(false)
const check = ()=>{
setisShow(!isShow)
}
return (
<div>
{/*第一种方式,用style来显示隐藏*/}
<button style={{display:isShow?'block':'none'}}>张三</button>
<button style={{display:isShow?'none':'block'}}>李四</button>
<button onClick={()=>check()}>点击切换</button>
</div>
)
}