在字体大小一致的前提下,Select组件中显示的文本相较Text组件中的文本,视觉上更为粗重。
问题代码示例参考如下:
@Entry @Component struct SelectExample { @State text: string = '这是实验组'; @State index: number = 0; build() { Column({ space: 10 }) { // icon可以使用其他有效资源 Select([{ value: 'aaa', icon: $r('app.media.startIcon') }]) .selected(this.index) .value(this.text) .font({ size: 35 }) .optionWidth(200) .optionHeight(300) .onSelect((index: number, text?: string | undefined) => { this.index = index; if (text) { this.text = text; } }); Text('这是对照组') .fontSize(35); } .width('100%') .height('100%') .justifyContent(FlexAlign.Center); } }
问题效果预览:

为Select组件的font属性添加weight参数,并将值设置为FontWeight枚举类型的Normal。
完整示例参考如下:
@Entry @Component struct SelectBold { @State text: string = '这是实验组'; @State index: number = 0; build() { Column({ space: 10 }) { // icon可以使用其他有效资源 Select([{ value: 'aaa', icon: $r('app.media.startIcon') }]) .selected(this.index) .value(this.text) .font({ size: 35, weight: FontWeight.Normal }) .optionWidth(200) .optionHeight(300) .onSelect((index: number, text?: string | undefined) => { this.index = index; if (text) { this.text = text; } }); Text('这是对照组') .fontSize(35); } .width('100%') .height('100%') .justifyContent(FlexAlign.Center); } }