SnackBar
- category: UI
- chinese: 图标
- type: UI 组件
何时使用
materialdesign 风格提示框,类似于 toast
API
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
bottom | 距离底部距离 | number | 0 |
message | 文案 | string | 无 |
duration | toast 出现多久后消失,默认 5 s | number | 5000 |
actionText | 按钮文本,如果不传则不展示按钮 | string | 无 |
action | 按钮点击回调 | boolean | false |
defaultVisible | 默认是否显示 | boolean | false |
maxLines | 最大行数 | number |
Breaking Change
由于第一版 SnackBar 阻塞用户其他行为,这与设计不符。在新版本中,不再使用 Mask。
demo
/** @jsx createElement */;;; const short1 = 'Thank you for your feedback!';const short2 = 'Successfully added to the cart Thank for your feedbac Successfully added to the cart Successfully added to the cart';let App = { super; thisstate = visible: false message: short1 ; thisshowBar = thisshowBar; thishideBar = thishideBar; thischangeMessage = thischangeMessage; } { thisrefssnackbarwrappedInstance; } { thisrefssnackbarwrappedInstance; } { this; } { return <Page title="SnackBar"> <PageIntro main="basic" sub="basic-sub" /> <Button onPress=thisshowBar type="primary"> click me </Button> <Button onPress=thischangeMessage type="primary"> changeMessage </Button> <SnackBar message=thisstatemessage bottom=80 ref="snackbar" defaultVisible=true actionText='DISMISS' action=thishideBar /> </Page> ; }; ;