弹出层 / ToastState状态提示组件
相比于Toast只能传递文本, ToastState顾名思义, 他还能传递Toast状态, 这里支持的状态由四类:
- success
- fail
- offline
- loading
其中, success, fail, offline为Icon提示, loading使用的Spinner组件进行提示, 并且可以根据props定义设置Spinner状态.
ToastState.present('Bottom was added successfully')
2. 传入Message和Duration
ToastState.present('Bottom was added successfully',1000)
3. 传入Options对象
ToastState.present({
message: '只是文本',
duration: 3000,
dismissOnPageChange: true,
onDismiss () {
console.debug('2 onDismiss in promise success!')
}
})
ToastState.present({
message: '请稍后',
duration: 3000,
type: 'loading',
spinner: {
name:'ios'
},
cssClass: 'showCloseBtnToastCssClass',
dismissOnPageChange: true,
onDismiss () {
console.debug('5 onDismiss in promise success!')
}
})
ToastState.present({
message: '请求成功',
duration: 3000,
type: 'success',
cssClass: 'showCloseBtnToastCssClass',
dismissOnPageChange: true,
onDismiss () {
console.debug('5 onDismiss in promise success!')
}
})
4. present方法
ToastState.present('Bottom was added successfully',1000)
- 源码:
传入属性 / Props:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
message |
String | Toast显示的message, 如果文本过程则折行并自动撑开容器 | ||
duration |
Number |
<optional> |
3000
|
Toast开启时间, 过期后关闭 |
cssClass |
String |
<optional> |
额外的样式定义, 多个样式使用空格隔开 | |
dismissOnPageChange |
Boolean |
<optional> |
false
|
当导航切换时, 是否自动关闭, 默认不关闭 |
onDismiss |
String |
<optional> |
noop
|
当关闭动画结束时执行的函数 |
spinner |
Object |
<optional> |
Spinner组件的props对象 | |
type |
String |
<optional> |
''
|
toast 类型,展示相应图标,类型可选值: success, fail, offline, loading |