From ed037924476065c7af39946789e47abcc18496f5 Mon Sep 17 00:00:00 2001 From: liugang9704 <2745340733@qq.com> Date: Thu, 3 Jul 2025 15:51:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=BF=9B=E5=85=A5=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E9=87=8D=E6=96=B0=E5=9B=9E=E5=88=B0=E9=A1=B5=E9=9D=A2=E6=97=B6?= =?UTF-8?q?=E4=BC=9A=E6=96=B0=E5=A2=9E=E5=AD=97=E7=AC=A6=E4=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ArkUI/entry/src/main/ets/pages/RenderText_2.ets | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ArkUI/entry/src/main/ets/pages/RenderText_2.ets b/ArkUI/entry/src/main/ets/pages/RenderText_2.ets index 037d0d1..3990daa 100644 --- a/ArkUI/entry/src/main/ets/pages/RenderText_2.ets +++ b/ArkUI/entry/src/main/ets/pages/RenderText_2.ets @@ -1,29 +1,30 @@ /** * FAQ:使用Text嵌套Span或者使用熟悉字符串渲染文本,部分文本颜色显示异常 */ -import { LengthMetrics } from '@kit.ArkUI'; // [Start render_text_2] +import { LengthMetrics } from '@kit.ArkUI'; + @Entry @Component struct Index { textController: TextController = new TextController(); - style1: MutableStyledString = new MutableStyledString(''); async onPageShow() { - this.style1.appendStyledString(new StyledString('sr', [{ + let style1: MutableStyledString = new MutableStyledString(''); + style1.appendStyledString(new StyledString('sr', [{ start: 0, length: 2, styledKey: StyledStringKey.FONT, styledValue: new TextStyle({ fontColor: Color.Blue, fontSize: LengthMetrics.px(150) }) }])); - this.style1.appendStyledString(new StyledString('fff', [{ + style1.appendStyledString(new StyledString('fff', [{ start: 0, length: 5, styledKey: StyledStringKey.FONT, styledValue: new TextStyle({ fontColor: Color.Orange, fontSize: LengthMetrics.px(150) }) }])); - this.textController.setStyledString(this.style1); + this.textController.setStyledString(style1); } build() { -- Gitee