代码拉取完成,页面将自动刷新
material-dialogs是自定义对话框库。
ohpm install @ohos/material-dialogs
import { MaterialDialog } from '@ohos/material_dialogs'
@State model: MaterialDialog.Model= new MaterialDialog.Model();
dialogController: CustomDialogController = new CustomDialogController({
builder: MaterialDialog({
model: this.model
}),
cancel: this.existDialog,
autoCancel: true,
alignment: DialogAlignment.Center
})
this.model.reset()
this.model.message($r('app.string.useOhosLocationServicesPrompt'))
this.model.positiveButton($r('app.string.agree'), {
onClick() {
console.info('ClickCallback when the confirm button is clicked')
}
})
this.model.negativeButton($r('app.string.disagree'), {
onClick() {
console.info('ClickCallback when the cancel button is clicked')
}
})
this.model.setScrollHeight(120)
this.dialogController.open()
@State model: MaterialDialog.Model= new MaterialDialog.Model();
model.icon()
model.title()
model.message()
model.positiveButton()
model.negativeButton()
model.neutralButton()
model.setStacked()
model.checkBoxPrompt()
model.setActionButtonEnabled()
model.listItems()
model.listItemsSingleChoice()
model.listItemsMultiChoice()
model.input()
model.colorChooser()
model.dateTimePicker()
在下述版本验证通过:
DevEco Studio: 4.0 Beta2(4.0.3.512), SDK: API10 (4.0.10.9)
DevEco Studio: 4.0 Canary1(4.0.0.112), SDK: API10 (4.0.7.2)
|---- material-dialogs
| |---- entry # 示例代码文件夹
| |---- material_dialogs # material_dialogs库文件夹
| |---- index.ets # 对外接口
| |---- src
| |---- main
| |---- components
| |---- MaterialDialog.ets # 自定义组件类
| |---- ClickCallback.ets # 点击事件
| |---- InputCallback.ets # 输入内容变化事件
| |---- ItemListener.ets # 条目点击事件
| |---- README.md # 安装使用方法
使用过程中发现任何问题都可以提 Issue 给我们,当然,我们也非常欢迎你给我们发 PR 。
本项目基于 Apache License 2.0 ,请自由地享受和参与开源。
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。