@Component export struct CardContainer { @Prop radius: number | string = 16 @Prop bgColor: string = '#FFFFFF' @Prop shadowColor: string = '#000000' @Prop shadowOpacity: number = 0.1 @Prop blurRadius: number = 40 @Prop cardColor: Color = Color.White @Prop paddings: Padding | Length = 0 @Prop margins: Margin = {} // 是否裁剪超出部分 @Prop needClip: boolean = true @BuilderParam children: () => void = this.content build() { Stack() { // 内容插槽 this.children() } .padding(this.paddings) .borderRadius(this.radius) .backgroundColor(this.bgColor) .margin(this.margins) .clip(this.needClip) .shadow({ radius: this.blurRadius, color: this.shadowColor.replace("#", "#" + Math.round(this.shadowOpacity * 255).toString(16).padStart(2, '0')), offsetX: 0, offsetY: 0 }) } @Builder content() { } }