1:组件样式
new Navbar("样式"), new Button { new Text("样式1") .FontColor("red") .FontSize(36f.Rpx()) } .WidthFull() .Height(100f.Rpx()) .BackgroundColor("white")2:样式抽离
// 通过定义一个Styles类,创建一个新的Style扩展方法。 [Styles] public static class CommonStyle { // 支持扩展块和标准扩展方法 extension(Text text) { public Text BlueText() => text .FontColor("#007AFF") .FontSize(36f.Rpx()); } } public override Widget Build() => new Column { new Navbar("样式"), new Button { new Text("样式2") .BlueText() // 一样的方式去调用 } .WidthFull() .Height(100f.Rpx()) .BackgroundColor("white") };3: 隔离性
通过C#命名空间就能很好的对样式进行隔离