快應(yīng)用 彈窗

2020-08-10 13:49 更新

接口聲明

{"name": "system.prompt"}

導(dǎo)入模塊

import prompt from '@system.prompt' 或 const prompt = require('@system.prompt')

接口定義

prompt.showToast(OBJECT)

顯示Toast

參數(shù):

參數(shù)名 類(lèi)型 必填 說(shuō)明
message String 要顯示的文本
duration Number 0為短時(shí),1為長(zhǎng)時(shí),默認(rèn)0

示例:

prompt.showToast({
  message: 'message'
})

prompt.showDialog(OBJECT)

顯示對(duì)話(huà)框

參數(shù):

參數(shù)名 類(lèi)型 必填 說(shuō)明
title String 標(biāo)題
message String 內(nèi)容
buttons Array 按鈕的數(shù)組,按鈕結(jié)構(gòu):{text:'text',color:'#333333'},color可選:buttons的第1項(xiàng)為positive button;buttons的第2項(xiàng)(如果有)為negative button;buttons的第3項(xiàng)(如果有)為neutral button。最多支持3個(gè)button
success Function 成功回調(diào)
cancel Function 取消回調(diào)
complete Function 執(zhí)行結(jié)束后的回調(diào)
success返回值:
參數(shù)名 類(lèi)型 說(shuō)明
index Integer 選中按鈕在buttons數(shù)組中的序號(hào)

示例:

prompt.showDialog({
  title: 'title',
  message: 'message',
  buttons: [
    {
      text: 'btn',
      color: '#33dd44'
    }
  ],
  success: function (data) {
    console.log('handling callback')
  },
  cancel: function (data) {
    console.log('handling cancel')
  },
  fail: function (data, code) {
    console.log(`handling fail, code = ${code}`)
  }
})

prompt.showContextMenu(OBJECT)

顯示上下文菜單

參數(shù):

參數(shù)名 類(lèi)型 必填 說(shuō)明
itemList Array 按鈕的文字?jǐn)?shù)組
itemColor HexColor 按鈕顏色
success Function 成功回調(diào)
cancel Function 取消回調(diào)
complete Function 執(zhí)行結(jié)束后的回調(diào)
success返回值:
參數(shù)名 類(lèi)型 說(shuō)明
index Integer 選中按鈕在itemList數(shù)組中的序號(hào)

示例:

prompt.showContextMenu({
  itemList: [
    'item1',
    'item2'
  ],
  itemColor: '#ff33ff',
  success: function (data) {
    console.log('handling callback')
  },
  cancel: function (data) {
    console.log('handling cancel')
  },
  fail: function (data, code) {
    console.log(`handling fail, code = ${code}`)
  }
})

后臺(tái)運(yùn)行限制

禁止使用。后臺(tái)運(yùn)行詳細(xì)用法參見(jiàn) 后臺(tái)運(yùn)行腳本。


以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)