Appearance
message
• Const
message: Object
页面提示、加载相关办法
See
Type declaration
Name | Type |
---|---|
hideLoading | () => void |
showIOErrorModal | (params : IOErrorModalParams , customMessage? : any ) => Promise <void > |
showLoading | (title : string , options? : ShowLoadingOptions ) => Promise <any > |
showModal | (content : string , options? : ShowModalOptions ) => void | Promise <ShowModalRes > |
showPrompt | (title : string , options? : ShowModalOptions ) => void | Promise <ShowModalRes > |
showToast | (title : string , options? : ShowToastOptions ) => Promise <void > |
hideLoading: () => void
隐藏 loading
示例
ts
message.hideLoading()
showIOErrorModal: (params
: IOErrorModalParams
, customMessage?
: any
) => Promise
<void
>
显示 io error modal
示例
ts
try {
throw new IOError({code: 10001, displayMessage: '请求失败'})
throw new IOError({
code: -1,
message: '601: request timeout',
displayMessage: '',
})
} catch (error) {
message.showIOErrorModal(error, {
10001: '优先显示自定义报错',
'request timeout': '网络超时',
default: '当最终文案为空时,使用该默认回退文案',
})
}
showLoading: (title
: string
, options?
: ShowLoadingOptions
) => Promise
<any
>
展示 loading
示例
ts
message.showLoading()
showModal: (content
: string
, options?
: ShowModalOptions
) => void
| Promise
<ShowModalRes
>
显示模态对话框
示例
ts
message
.showModal('这是一条询问', {
title: '提示',
})
.then(res => {
message.showToast(`你点击了${res.confirm ? '确定' : '取消'}`)
})
showPrompt: (title
: string
, options?
: ShowModalOptions
) => void
| Promise
<ShowModalRes
>
显示可输入模态对话框
示例
ts
message.showPrompt('请输入内容').then(res => {
if (res.confirm) {
message.showToast(`你输入了:${res.content}`)
return
}
message.showToast(`你点击了取消`)
})
showToast: (title
: string
, options?
: ShowToastOptions
) => Promise
<void
>
显示消息提示框
示例
ts
message.showToast('这是一个提示')
await message.showToast('这是一个可等待关闭的提示', {duration: 3000})