当前位置: 首页 > news >正文

网站建设 sql 模版集团网站建设费用

网站建设 sql 模版,集团网站建设费用,wordpress 插件阅读,九千营销工作室介绍鸿蒙通用组件弹窗简介 弹窗----Toast引入ohos.promptAction模块通过点击按钮,模拟弹窗 警告对话框----AlertDialog列表弹窗----ActionSheet选择器弹窗自定义弹窗使用CustomDialog声明一个自定义弹窗在需要使用的地方声明自定义弹窗,完整代码 弹窗----Toa…

鸿蒙通用组件弹窗简介

  • 弹窗----Toast
    • 引入@ohos.promptAction模块
    • 通过点击按钮,模拟弹窗
  • 警告对话框----AlertDialog
  • 列表弹窗----ActionSheet
  • 选择器弹窗
  • 自定义弹窗
    • 使用@CustomDialog声明一个自定义弹窗
    • 在需要使用的地方声明
    • 自定义弹窗,完整代码

弹窗----Toast

在这里插入图片描述

引入@ohos.promptAction模块

import promptAction from '@ohos.promptAction'

通过点击按钮,模拟弹窗

Button('点击').width('60%').height(50).onClick(()=>{promptAction.showToast({message:'点击了按钮', // 展示的文字duration:2000, // 停留时长bottom: 100 // 距离底部多远})})

警告对话框----AlertDialog

AlertDialog用于向用户提出告警或者确认的对话框。

在这里插入图片描述

AlertDialog.show({title:'提示信息',message:'此信息比较重要,请确认!!!',autoCancel: true, //点击遮障层时,是否关闭弹窗alignment: DialogAlignment.Bottom, //弹窗位置offset: { dx: 0, dy: -30 }, //相对于弹窗位置的偏移量primaryButton: { //主要按钮value: '确认', //按钮内容fontColor: Color.Red, //字体颜色action: () => { //点击回调console.log('点击了确认按钮')}},secondaryButton: { //次要按钮value: '取消',action: () => {console.log('点击了取消按钮')}},cancel: () => { //点击遮罩层取消时的回调console.info('点击遮罩层取消时的回调')}
})

列表弹窗----ActionSheet

ActionSheet用于给用户一组列表弹窗,等用户选择后再作处理。

在这里插入图片描述

ActionSheet.show({
title:'提示信息',
message: '此信息比较重要,请确认!!!',
autoCancel: true, //点击遮障层时,是否关闭弹窗
alignment: DialogAlignment.Center, //弹窗位置
offset: { dx: 0, dy: -20 }, //弹窗相对alignment位置的偏移量
confirm: { //底部按钮value: '取消', //按钮文本内容action: () => { //按钮回调函数console.log('点击按钮取消')}
},
cancel: () => { //点击遮障层关闭弹窗时的回调console.log('点击遮障层取消')
},
sheets:[{title:'操作1',action: () => {console.log('操作1')}},{title:'操作2',action: () => {console.log('操作2')}},{title:'操作3',action: () => {console.log('操作3')}},
]
})

alignment的几种位置:

DialogAlignment.Top 上部
DialogAlignment.Center 中间
DialogAlignment.Bottom 底部
DialogAlignment.TopStart 左上部
DialogAlignment.TopEnd 右上部
DialogAlignment.CenterStart 中间左边
DialogAlignment.CenterEnd 中间右边
DialogAlignment.BottomStart 左下部
DialogAlignment.BottomEnd 右下部

选择器弹窗

鸿蒙API中有很多选择器弹窗,比如时间、日期、文本等,这里就不做介绍。

自定义弹窗

在实际使用过程中,一定会遇到官方提供的弹窗不能满足需要的情况,这时候就需要尽心自定义。

这里举一个自定义弹窗的简单例子

使用@CustomDialog声明一个自定义弹窗

@CustomDialog
struct CustomDialogText{controller: CustomDialogController = new CustomDialogController({ builder: CustomDialogText() })build(){Column({space: 20}){Text('内容1')Text('内容2')Text('内容3')}.margin(20).onClick(()=>{this.controller.close()})}
}

在build里面定义UI样式,这里只做为展示,随便定义了几个展示的文本内容

在需要使用的地方声明

在使用过程中,需要需要初始化CustomDialogController。

controller: CustomDialogController = new CustomDialogController({builder: CustomDialogText(),// builder就是自定义的弹窗alignment: DialogAlignment.Center, // 弹窗弹出位置offset:{dx: 0, dy: -10} // 弹窗弹出后的偏移量,按需要进行设置
})

定义好controller之后,在使用的时候,直接调用this.controller.open()。

在这里插入图片描述

自定义弹窗,完整代码

@Entry
@Component
struct CommentTest{controller: CustomDialogController = new CustomDialogController({builder: CustomDialogText(),alignment: DialogAlignment.Center,offset:{dx: 0, dy: -10}})build(){Column({space: 20}){Button('点击弹出自定义弹窗').width('60%').height(50).onClick(()=>{this.controller.open()})}.width('100%').height('100%').justifyContent(FlexAlign.Center)}
}@CustomDialog
struct CustomDialogText{controller: CustomDialogController = new CustomDialogController({ builder: CustomDialogText() })build(){Column({space: 20}){Text('内容1')Text('内容2')Text('内容3')}.margin(20).onClick(()=>{this.controller.close()})}
}
http://www.yayakq.cn/news/929868/

相关文章:

  • 网站建设知名公司排名百度app免费下载安装
  • 贵阳住房和城乡建设局网站wordpress评论去掉邮箱
  • 优秀设计网站大全山东一建建设有限公司网站
  • ps做的网站图片好大响应式网站建设网站
  • 网站建设公司问答营销案例建设部科技中心网站
  • 电商官方网站怎样注册网站免费的
  • 做英文网站哪个网站比较好网络公司经营范围参考
  • 网站后台购买帝国cms个人网站模板
  • 手机网站知识网站内外链接怎么做
  • 如何选择南京网站建设网页设计图片间距代码
  • 如何做好网站针对搜索引擎的seo长沙哪些公司做网站
  • wordpress改关键词百度关键词seo推广
  • 社群网站建设强强seo博客
  • 网网站建设有什么网站可以做毕业影像
  • 专业模板建站软件网站如何在百度刷排名
  • 做文案图片上什么网站金融网站建设公司
  • 东至网站制作大学生网站建设结题报告
  • 车辆对比那个网站做的好网站的主题是什么
  • 超炫网站页面新公司注册详细流程
  • 林河西网站建设网站后台登录密码修改
  • 怎样只做自己的网站头部互联网公司有哪些
  • 商务网站建设规划比较流行的网站建设技术有哪些
  • wordpress管局备案网站seo怎样做
  • 自己本地可以做网站服务器吗天翼电子商务有限公司
  • 企业网站托管服务公司wordpress用户修改邮箱
  • 找快照网站查询昆明网络营销咨询
  • 做民宿加盟哪些网站比较好简述网站设计的原则
  • 西安哪里做网站解决问题的网站
  • 好网站开发公司德阳建设机械网站
  • c 网站开发需要什么简述网站建设的方案