【发布时间】:2016-08-24 16:01:19
【问题描述】:
我是 SAPUI5 的新手,我正在尝试通过我的控制器在我的视图中将一个值设置为标签。
View1.controller.js
onInit: function()
{
var currentTime = this.whatsTheTime();
var currentDate = this.whatsTheDate();
this.getView().byId("timeDisplay").setValue(currentTime);
this.getView().byId("dateDisplay").setValue(currentDate);
this.repeat(function() {
currentTime = this.whatsTheTime();
currentDate = this.whatsTheDate();
this.getView().byId("timeDisplay").setText(currentTime);
this.getView().byId("dateDisplay").setText(currentDate);
}, 1000);
view.xml
<mvc:View controllerName="testApp.controller.View1" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m">
<Label id = "timeDisplay" design="Bold" />
<Label id = "dateDisplay" design="Bold"/>
<Button
text = "Click me"
press = "doNothing" />
</mvc:View>
基本上,在控制器中,whatsTheTime 和 whatsTheDate 都返回值,我试图将这些值设置到标签中。这是一件非常简单的事情,但我错过了一些东西,因为在我的控制台中
this.getView(...).byId(...).setValue is not a function
编辑:另外,在我的 onInit 函数中编写我的重复函数以每 1 秒运行一次,有什么特别的方法吗?因为它说重复不是一个函数。重复功能的重点是每 1 秒更新一次值。
为什么这会引发这个错误?
【问题讨论】:
标签: sapui5