点击登录

讨论 How to change text every second?

amongus1

Lv.0
社区会员
let __$$app$$__ = __$$hmAppManager$$__.currentApp; __$$module$$__ = __$$app$$__.current; let timeSensor = null; let textWidget = null; __$$module$$__.module = DeviceRuntimeCore.Page({ onInit() { timeSensor = hmSensor.createSensor(hmSensor.id.TIME) textWidget = hmUI.createWidget(hmUI.widget.TEXT, { x: 15, y: 200, w: DEVICE_WIDTH - 42 * 2, h: 42, color: 0xffffff, text_size: 24, align_h: hmUI.align.CENTER_H, align_v: hmUI.align.CENTER_V, text_style: hmUI.text_style.NONE, text: `${timeSensor.second}` }) textWidget.addEventListener(hmUI.event.CLICK_DOWN, (info) => { textWidget.setProperty(hmUI.prop.MORE, { y: 200 }) }) }, onShow() { }, onDestroy() { // On destroy, remove if not required } });

I am trying to set the text to timeSensor.second. however, it only happens once. How do I fix this
 
let __$$app$$__ = __$$hmAppManager$$__.currentApp; __$$module$$__ = __$$app$$__.current; let timeSensor = null; let textWidget = null; __$$module$$__.module = DeviceRuntimeCore.Page({ onInit() { timeSensor = hmSensor.createSensor(hmSensor.id.TIME) textWidget = hmUI.createWidget(hmUI.widget.TEXT, { x: 15, y: 200, w: DEVICE_WIDTH - 42 * 2, h: 42, color: 0xffffff, text_size: 24, align_h: hmUI.align.CENTER_H, align_v: hmUI.align.CENTER_V, text_style: hmUI.text_style.NONE, text: `${timeSensor.second}` }) textWidget.addEventListener(hmUI.event.CLICK_DOWN, (info) => { textWidget.setProperty(hmUI.prop.MORE, { y: 200 }) }) }, onShow() { }, onDestroy() { // On destroy, remove if not required } });

I am trying to set the text to timeSensor.second. however, it only happens once. How do I fix this
厉害
 

*这是一则由 Google AdSense 自动推荐的广告,与本站无关,不对其真实性与可靠性负责

相似主题

米环7小程序
11K
267

Home 首页
Home 资源
News 发现
Account 我的
顶部