#鸿蒙学习大百科#如何显示带符号的数字?

如何显示带符号的数字?

HarmonyOS
2024-10-29 09:51:18
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
后知后觉cy
// 导入模块
import { intl } from '@kit.LocalizationKit';

@Entry
@Component
struct Index {
  @State str: string = ''
  aboutToAppear(): void {
    // 显示数字的符号
    let numberFormat3 = new intl.NumberFormat('zh-CN', {signDisplay: 'always'});
    this.str = numberFormat3.format(123400); // formattedNumber3: +123,400
  }
  build() {
    Column() {
      Text(this.str)
        .fontSize(30)
        .margin(20)
    }
    .height("100%")
    .width('100%')
    .justifyContent(FlexAlign.Center)
  }
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
分享
微博
QQ
微信
回复
2024-10-29 15:23:39
相关问题
#鸿蒙学习大百科#ArkTS如何生成xml?
1200浏览 • 1回复 待解决