使用setTimeout延迟后隐藏/显示元素

时间:2014-10-23 08:47:04

标签: javascript sapui5

我在视图上有示例文本元素。如何在延迟3秒后隐藏它们? 使用setTimeout()不起作用。

这是我的观看代码。

<core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"     xmlns:l="sap.ui.layout"
        controllerName="setvisible.Index" xmlns:html="http://www.w3.org/1999/xhtml">
    <Page title="Title">
        <content>
            <Text id="sampleText" text="Test" visible="true"/>
            <Button id="hide" text="Hide" press="hide"/>
        </content>
    </Page>
</core:View>

这是我的控制器代码。

sap.ui.controller("setvisible.Index", {
hide: function(oEvent) {
    setTimeout(showElem, 3000);
    function showElem() {
         this.byId("sampleText").setVisible(true);
         this.getView();
    }

}
});

错误是未捕获的TypeError:undefined不是函数。

1 个答案:

答案 0 :(得分:-2)

控制sap.m.BusyDialog()导致此错误,如果使用sap.m.Dialog(),它将起作用。