confirm

弹出带两个或三个按钮的confirm对话框

confirm({params}, callback(ret, err))

params

title:

  • 类型:字符串
  • 默认值:无
  • 描述:(可选项)标题

msg:

  • 类型:字符串
  • 默认值:无
  • 描述:(可选项)内容

buttons:

  • 类型:字符串数组
  • 默认值:[“取消”,”确定”]
  • 描述:(可选项)按钮标题,若小于两个按钮,会补齐两个按钮;若大于三个按钮,则使用前三个按钮

callback(ret, err)

ret:

  • 类型:JSON 对象
  • 内部字段:
  1. {
  2. buttonIndex:1 //按钮点击序号,从1开始
  3. }

示例代码

  1. api.confirm({
  2. title: 'testtitle',
  3. msg: 'testmsg',
  4. buttons: ['确定', '取消']
  5. }, function(ret, err) {
  6. var index = ret.buttonIndex;
  7. });

补充说明

多个按钮的对话框

可用性

iOS系统,Android系统

可提供的1.0.0及更高版本