SAPUI5 this.getView(…).byId(…).setValue不是函数

SAPUI5 this.getView(…).byId(…).setValue不是函数,sapui5,Sapui5,我是SAPUI5的新手,我正试图通过控制器在视图中的标签中设置一个值 View1.controller.js onInit: function() { var currentTime = this.whatsTheTime(); var currentDate = this.whatsTheDate(); this.getView().byId("timeDisplay").setValue(currentT

我是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不是函数

编辑:另外,在编写我的repeat函数时,是否有任何特殊的方法在我的onInit函数中每隔1秒运行一次?因为它说重复不是一种功能。repeat函数的要点是每1秒更新一次值


这到底是为什么让我产生这个错误?

标签没有Value属性,所以没有setValue函数(在错误文本中报告),但它有“text”属性,所以您应该执行以下操作:

this.getView(...).byId(...).setText( ... )

Label没有Value属性,因此没有setValue函数(在错误文本中报告),但它具有“text”属性,因此您应该执行以下操作:

this.getView(...).byId(...).setText( ... )

天啊,我真傻!非常感谢。还有最后一个问题。我编辑了我的问题,又添加了一个bug,你也能看看吗?这里有一个很好的例子:哦,天哪,我真傻!非常感谢。还有最后一个问题。我已经编辑了我的问题并添加了一个错误,请您也看一下好吗?这里有一个很好的例子: