中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
微信扫码分享
啥都不说了,我直接上码: @Entry @Component struct Index { build() { Column() { Column() { Text('无`WithTheme`') .fontSize(40) .fontWeight(FontWeight.Bold) } .justifyContent(FlexAlign.Center) .width('100%') .height('33%') .backgroundColor($r('sys.color.background_primary')) WithTheme({ colorMode: ThemeColorMode.DARK }) { Column() { Text('WithTheme') .fontSize(40) .fontWeight(FontWeight.Bold) Text('DARK') .fontSize(40) .fontWeight(FontWeight.Bold) } .justifyContent(FlexAlign.Center) .width('100%') .height('33%') .backgroundColor($r('sys.color.background_primary')) } WithTheme({ colorMode: ThemeColorMode.LIGHT }) { Column() { Text('WithTheme') .fontSize(40) .fontWeight(FontWeight.Bold) Text('LIGHT') .fontSize(40) .fontWeight(FontWeight.Bold) } .justifyContent(FlexAlign.Center) .width('100%') .height('33%') .backgroundColor($r('sys.color.background_primary')) } } .height('100%') .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.END, SafeAreaEdge.BOTTOM, SafeAreaEdge.START]) } }