// @Preview
import {ICallBack } from '../base/model/NetHandler';
export type ICallBack=()=>void;
/*
//例子
* 必须声明全局变量
* controller?: CustomDialogController
* 单按钮通过判断按钮title显示
* 左右按钮回调方法 可选
this.controller = new CustomDialogController({
builder: BusAlert({
leftBtnTitle:'shishi',
rightBtnTitle:'haode',
leftAction:()=>{
console.log('左边方法')
},
rightAction:()=>{
console.log('右边方法')
},
title:'测试',
content:'我就试试'
}),
// autoCancel: true, // 允许点击蒙层关闭弹窗
customStyle: true, // 使用自定义样式
alignment: DialogAlignment.Center
})
this.controller.open()
* */
@Preview
@CustomDialog
export struct BusAlert {
@Prop title: string = '';
@Prop content: string = '';
@Prop leftBtnTitle: string = '';
@Prop rightBtnTitle: string = '';
leftAction?:ICallBack
rightAction?:ICallBack
controller: CustomDialogController
build() {
Stack() {
Column() {
Text(this.title)
.fontSize(16)
.fontWeight(FontWeight.Medium)
.margin({ top: 3 })
Text(this.content)
.fontSize(14)
.margin({ top: 24 })
Row({ space: 16 }) {
if (this.leftBtnTitle) {
Text(this.leftBtnTitle)
.height(40)
// .width(115)
.layoutWeight(1)
.textAlign(TextAlign.Center)
.fontSize(15)
.fontColor($r('app.color.font3474ee'))
.borderRadius(20)
.borderWidth(1)
.borderColor($r('app.color.font3474ee'))
.onClick(() => {
this.controller.close(); // 关闭弹窗
if (this.leftAction) {
this.leftAction()
}
})
}
if (this.rightBtnTitle) {
Text(this.rightBtnTitle)
.textAlign(TextAlign.Center)
.fontSize(15)
.fontColor(Color.White)
.height(40)
.layoutWeight(1)
.backgroundColor($r('app.color.font3474ee'))
.borderRadius(20)
.onClick(() => {
this.controller.close(); // 关闭弹窗
if (this.rightAction) {
this.rightAction()
}
})
}
}
.height(40)
.width('100%')
.margin({
top: 35,
bottom: 18
})
}
.padding({
top:12,
left: 19,
right: 19
})
.backgroundColor(Color.White)
.borderRadius(8)
.width(280)
}
// .margin({left: 40, right: 40})
// .width("100%")
}
}
鸿蒙自定义弹窗的使用
原创wx668d2b0859204 博主文章分类:鸿蒙 ©著作权
文章标签 Text 自定义样式 回调方法 文章分类 TypeScript 前端开发
下一篇:Mac连接设备USB断断续续
-
GBDT为什么使用梯度提升
前言 在上一章中我们了解了线性回归求最小值的方法(损失函数最小化),直接对其求导,即正规方程方法。 但是在机器学习中,像线性回归这样可以直接用数学公式推导出最小值的算法是很少的,绝大多数的损失函数是很复杂的,所以我们来介绍一种更为通用,也是机器学习中很重要的一种优化方法,即梯度下降法。 梯度下降法是机器学习中的一种优化算法,并非机器学习算法。 梯度简单的可以理解为多元函数的
GBDT为什么使用梯度提升 3. 机器学习中为什么需要梯度下降 机器学习中为什么需要梯度下降 梯度下降法 损失函数 -
Android的系统给提供的图在哪
一、Android平台架构及特征 Android系统建立在Linux系统之上,分为4层:操作系统内核、中间件、用户界面、应用软件。 可以看到,这4层架构主要由5部分组成:用户程序、用户程序框架、C/C++函数库、Android运行时、Linux内核。 &nbs
Android的系统给提供的图在哪 android Android xml文件