其他

遍历组件

ForEach(this.list,(item:Type,idx)={
myComponent({myVal:item})
})
struct myComponet{
myVal:TYPE
}

Button

Button('sss')
.enabled(this.isSelect)

Checkbox

Checkbox()
.select($$this.isSelect)

Refresh

下拉刷新

Refresh({
refreshing:$$this.isRefresh,
builder:this.Refresh()}){
}
.onRefreshing(()=>{
setTimeout(()=>{
this.changeRefreshLoading()
AlertDialog.show({message:'ok'})
},200)
}

@Builder
Refresh(){
Progress({
value:this.freshVal,
total:100,
type:ProgressType.Ring
})
}

TextTimer

textTimerController: TextTimerController = new TextTimerController()
TextTimer({ isCountDown: false, controller: this.textTimerController })
.format(this.format)
.fontSize(15)
.margin({top:20})
.fontWeight(FontWeight.Bold)
.onTimer((utc: number, elapsedTime: number) => {

})
this.textTimerController.reset()
Search()

Text

Text(this.data.toString())
.textOverflow({ overflow: TextOverflow.None })
.maxLines(1)

Scroll

scroller:Scroller = new Scroller()
Scroll(this.scroller) {

}
.scrollable(ScrollDirection.Vertical)
.scrollBar(BarState.On)
.scrollBarColor(Color.Gray)
.scrollBarWidth(10)
.edgeEffect(EdgeEffect.Spring)

Swiper

swiperController: SwiperController = new SwiperController()
Swiper()
.index($$this.idx)
.autoPlay(false)
.indicator(false)

TextInput

TextInput({placeholder:'',text:&&this.message})

Divider

下划线

Divider()

Image

Image()
.borderRadius()//more large,more circle
.onAreaChange((oldValue: Area, newValue: Area=> {
AlertDialog.show({
message:'f'+newValue.width
})
}))

弹窗

//showToast
promptAction.showToast({ message: 'nreivn' })

//AlertDialog
AlertDialog.show()

//@customDialog
////父:
@Entry
@Component
struct Parent{
controller: CustomDialogController = new CustomDialogController({
builder: Son1(),
autoCancel: true,
// alignment: DialogAlignment.Bottom,
offset: { dx: 0, dy: 0 },
// gridCount: 4,s
customStyle: false,
// backgroundColor: 0xd9ffffff,
cornerRadius: 20,
width: '100%',
height: '100%',
borderWidth: 1,
// borderStyle: BorderStyle.Dashed,//使用borderStyle属性,需要和borderWidth属性一起使用
// borderColor: Color.Blue,//使用borderColor属性,需要和borderWidth属性一起使用
// shadow: ({ radius: 20, color: Color.Grey, offsetX: 50, offsetY: 0}),
})
build(){
this.controller.open()
}
}
//嵌套弹窗
////子1:
@CustomDialog
export struct Son1{
Controller1: CustomDialogController = new CustomDialogController({
builder: Son1(),
autoCancel: true,
// alignment: DialogAlignment.Bottom,
offset: { dx: 0, dy: 0 },
// gridCount: 4,
customStyle: false,
// backgroundColor: 0xd9ffffff,
cornerRadius: 20,
width: '100%',
height: '100%',
borderWidth: 1,
// borderStyle: BorderStyle.Dashed,//使用borderStyle属性,需要和borderWidth属性一起使用
// borderColor: Color.Blue,//使用borderColor属性,需要和borderWidth属性一起使用
// shadow: ({ radius: 20, color: Color.Grey, offsetX: 50, offsetY: 0}),
})
Controller2: CustomDialogController = new CustomDialogController({
builder: Son2(),
autoCancel: true,
// alignment: DialogAlignment.Bottom,
offset: { dx: 0, dy: 0 },
// gridCount: 4,
customStyle: false,
// backgroundColor: 0xd9ffffff,
cornerRadius: 20,
width: '100%',
height: '100%',
borderWidth: 1,
// borderStyle: BorderStyle.Dashed,//使用borderStyle属性,需要和borderWidth属性一起使用
// borderColor: Color.Blue,//使用borderColor属性,需要和borderWidth属性一起使用
// shadow: ({ radius: 20, color: Color.Grey, offsetX: 50, offsetY: 0}),
})
build(){
this.Controller1.close()
this.controller2.open()
}
}
////子2:
@CustomDialog
export struct Son2{
dialogController: CustomDialogController = new CustomDialogController({
builder: Son2(),
autoCancel: true,
// alignment: DialogAlignment.Bottom,
offset: { dx: 0, dy: 0 },
// gridCount: 4,
customStyle: false,
// backgroundColor: 0xd9ffffff,
cornerRadius: 20,
width: '100%',
height: '100%',
borderWidth: 1,
// borderStyle: BorderStyle.Dashed,//使用borderStyle属性,需要和borderWidth属性一起使用
// borderColor: Color.Blue,//使用borderColor属性,需要和borderWidth属性一起使用
// shadow: ({ radius: 20, color: Color.Grey, offsetX: 50, offsetY: 0}),
})
build(){
this.dialogController.close()
}
}
//自定义