ets声明式ui开发,怎么获取当前系统时间
Posted 大前端之旅
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ets声明式ui开发,怎么获取当前系统时间相关的知识,希望对你有一定的参考价值。
ets声明式ui开发,怎么获取当前系统时间
在这里,我们将字符串用@state包裹,这样可以监听数据的更新
我们给Text绑定点击时间,然后点击,即可显示当前时间,下面是效果。
@Entry
@Component
struct Index
@State message: string = Hello World
build()
Row()
Column()
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold).onClick(()=>
let date = new Date()
//获取当前时间
// this.message=date.toLocaleString();
//周几
// this.message=date.getUTCDay().toString();
//日期
// this.message=date.getUTCDate().toString();
// //农历月份
// this.message=date.getUTCMonth().toString();
this.message=date.getFullYear() + "年" + (date.getMonth() + 1) + "月" + date.getDate() + "日" + date.getHours() + "时" + date.getMinutes() + "分" + date.getSeconds()+ "秒"
)
.width(100%)
.height(100%)
以上是关于ets声明式ui开发,怎么获取当前系统时间的主要内容,如果未能解决你的问题,请参考以下文章
声明式 UI 编程探索-构建 SwiftUI 风格的 UI 框架 | GMTC
Components for Android: 一个高效的声明式UI框架
Components for Android: 一个高效的声明式UI框架