#鸿蒙学习大百科#如果空间不足如何显示简短的时间信息?

如果空间不足如何显示简短的时间信息?

HarmonyOS
2024-10-29 09:42:42
1209浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
莫名瞄一眼
// 导入模块
import { intl } from '@kit.LocalizationKit';

@Entry
@Component
struct Index {
  @State time: string = ''

  build() {
    Column() {
      Text(this.time).fontSize(20)
        .margin(10)
      Button("点击").onClick(() => {
        // 设置要格式化的日期
        let date = new Date(2021, 8, 17, 13, 4, 0);
        let dateFormat2 = new intl.DateTimeFormat('zh-CN', { dateStyle: 'short', timeStyle: 'short' });
        this.time = dateFormat2.format(date); // formattedDate2: 2021/9/17 13:04
      })
    }
    .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.
  • 24.

分享
微博
QQ
微信
回复
2024-10-29 16:11:33
相关问题
#鸿蒙学习大百科#ArkTS如何生成xml?
1236浏览 • 1回复 待解决