合作咨询
我们的专家服务团队将竭诚为您提供专业的合作咨询服务
代码如下:
@Component
struct DeviceStr{
@Link listData:Array<string>
@BuilderParam head1:() => void
@BuilderParam bodyList:(list:Array<string>) => void
build() {
Column(){
Column(){
this.head1()
}.flexBasis(30).justifyContent(FlexAlign.Center).backgroundColor("#E99")
.width("100%")
Column(){
this.bodyList(this.listData)
}.height(200).backgroundColor("#E0E").width("100%")
}
}
}
@Component
@Preview
export default struct Test {
@State array:Array<string> = [
"张三","李四","王五"]
@State array1:Array<string> = [
"张三1","李四1","王五1"]
@Builder
tbHead():ESObject{
Row(){
Text("角色列表").fontColor("#0F0")
}.width(200).backgroundColor("#00F")
}
@Builder
tbBody(data:Array<string>):ESObject{
List(){
ForEach(data,(item:string)=>{
ListItem(){
Text(item)
}
})
}
}
build() {
Column() {
Row() {
Text("插槽函数").fontSize(20).fontWeight(FontWeight.Bold).fontColor("#FFF")
}.backgroundColor("#ff115d19").width("100%").justifyContent(FlexAlign.Center)
.padding(10)
DeviceStr({
listData:$array,
head1:this.tbHead(),
bodyList:this.tbBody(this.array1)
})
}.width("100%").height("100%")
}
}
我要提问题