鸿蒙代码@Builder
#代码如下:
@Entry
@Component
struct CardExample {@State title: string = "欢迎使用鸿蒙";@State content: string = "这是一段自定义内容";build() {Column() {this.MyCard({ title: this.title, content: this.content })}.padding(20)}@BuilderMyCard(props: { title: string, content: string }) {Column() {Text(props.title).fontSize(20).fontWeight(FontWeight.Bold).margin({ bottom: 10 })Text(props.content).fontSize(16).textAlign(TextAlign.Start)}.padding(20).backgroundColor(Color.White).borderRadius(10).shadow({ radius: 10, color: '#00000033', offsetX: 0, offsetY: 4 })}
}
运行结果: