警告框,可以设置警告框的标题、内容、按钮文字等,暂不支持设置图片等样式。
示例代码
// API-DEMO page/API/alert/alert.json
{
"defaultTitle": "Alert"
}
<!-- API-DEMO page/API/alert/alert.axml-->
<view class="page">
<view class="page-description">警告框 API</view>
<view class="page-section">
<view class="page-section-title">my.alert</view>
<view class="page-section-demo">
<button type="primary" onTap="alert">显示警告框</button>
</view>
</view>
</view>
// API-DEMO page/API/alert/alert.js
Page({
alert() {
my.alert({
title: '亲',
content: '您本月的账单已出',
buttonText: '我知道了',
success: () => {
my.alert({
title: '用户点击了「我知道了」',
});
}
});
},
})
入参
Object 类型,属性如下:
属性 | 类型 | 必填 | 描述 |
title | String | 否 | 警告框的标题。 |
content | String | 否 | 警告框的内容。 |
buttonText | String | 否 | 按钮文字,默认为 “确定”。 |
success | Function | 否 | 调用成功的回调函数。 |
fail | Function | 否 | 调用失败的回调函数。 |
complete | Function | 否 | 调用结束的回调函数(调用成功、失败都会执行)。 |
在文档使用中是否遇到以下问题
更多建议
匿名提交