Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 1x 1x | import React, { useState } from "react"; import { Alert } from "@tencent/tea-component/lib/alert"; import { Button } from "@tea/component/button"; export default function AlertCloseExample() { const [alertVisible, setAlertVisible] = useState(true); return ( <> <Alert defaultVisible style={{ marginTop: 10 }}> 非受控关闭 </Alert> <Alert type="warning" visible={alertVisible} onClose={() => setAlertVisible(false)} extra={ <Button type="link" onClick={() => setAlertVisible(false)}> 关闭 </Button> } > 受控关闭 </Alert> </> ); } |