File tree Expand file tree Collapse file tree 1 file changed +29
-12
lines changed
src/packages/toast/demos/h5 Expand file tree Collapse file tree 1 file changed +29
-12
lines changed Original file line number Diff line number Diff line change 1- import React from 'react'
1+ import React , { useState } from 'react'
22import { Toast , Cell , Button } from '@nutui/nutui-react'
33
44const Demo2 = ( ) => {
@@ -16,6 +16,17 @@ const Demo2 = () => {
1616 } )
1717 }
1818
19+ const [ neverDisappear , setNeverDisappear ] = useState ( false )
20+
21+ const hideToastStyle : React . CSSProperties = neverDisappear
22+ ? {
23+ position : 'fixed' ,
24+ top : '53%' ,
25+ left : '35%' ,
26+ zIndex : 9999 ,
27+ }
28+ : { }
29+
1930 return (
2031 < >
2132 < Cell
@@ -28,18 +39,24 @@ const Demo2 = () => {
2839 title = "Toast 不消失"
2940 onClick = { (
3041 event : React . MouseEvent < HTMLDivElement , globalThis . MouseEvent >
31- ) => permanentToast ( 'Toast 不消失' ) }
32- />
33- < Button
34- style = { { margin : 8 } }
35- type = "primary"
36- shape = "round"
37- onClick = { ( ) => {
38- Toast . clear ( )
42+ ) => {
43+ setNeverDisappear ( true )
44+ permanentToast ( 'Toast 不消失' )
3945 } }
40- >
41- 隐藏Toast
42- </ Button >
46+ />
47+ < div style = { hideToastStyle } >
48+ < Button
49+ style = { { margin : 8 } }
50+ type = "primary"
51+ shape = "round"
52+ onClick = { ( ) => {
53+ setNeverDisappear ( false )
54+ Toast . clear ( )
55+ } }
56+ >
57+ 隐藏Toast
58+ </ Button >
59+ </ div >
4360 </ >
4461 )
4562}
You can’t perform that action at this time.
0 commit comments