示例
何时使用
- 可提供成功、警告、错误等反馈信息
- 视窗右上角落按顺序弹出、需要手动关闭
- 系统主动推送
基本用法
点击按钮触发,可自定义内容与按钮功能
PCPhonePad
<page>
<actions>
<button bindclick="openAlertText('info')" text="默认通知"/>
<button bindclick="openAlertText('success')" text="成功通知"/>
<button bindclick="openAlertText('warning')" text="警告通知"/>
<button bindclick="openAlertText('error')" text="错误通知"/>
<button bindclick="openAlertText('success')" text="自定义按钮"/>
</actions>
</page>
export default XPage({
data: {},
openAlertText(type='error') {
let time = (new Date()).getTime();
CabinX.message({
title: '我是标题我是标题我是标题我是标题我是标题我是标题我是标题我是标题我是标题我是标题我是标题我是标题我是标题我是标题',
text: '朕已经知道了朕已经知道了朕已经知道了朕已经知道了朕已经知道了朕已经知道了朕已经知道了朕已经知道了朕已经知道了朕已经知道了朕已经知道了朕已经知道了朕已经知道了' + time,
status: type,
ok: {
text: '知道了',
onClick: () => {
},
}
});
},
});
Attributes
参数 | 说明 | 类型 | 可选值 | 默认值 | 端 | 版本 |
---|---|---|---|---|---|---|
title | 弹框标题 | string | -- | -- | PC/Mobile | -- |
text | 弹框标题 | string | -- | -- | PC/Mobile | -- |
status | 状态 | string | info / success / warning / error | info | PC/Mobile | -- |
ok | 按钮 | object,参考OK属性说明 | -- | -- | PC/Mobile | -- |
ok
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|---|---|---|---|
text | 按钮文案 | string | -- | -- |
onClick | 点击回调函数 | function | -- | -- |
使用
let instance=CabinX.message({
title: '我是标题',
text: '朕已经知道了',
status: 'success',
ok: {
text: '知道了',
onClick: () => {
},
}
});
//更新
instance.update({
text:'修改了'
});