gpt4 book ai didi

sapui5 - 如何在 Controller 外检索 View

转载 作者:行者123 更新时间:2023-11-29 10:14:57 24 4
gpt4 key购买 nike

如果我使用 this.getView()在 View 的 Controller 内,我可以毫无问题地检索它。

如果我在 Controller 之外(例如,在另一个 View 的 Controller 中),如何检索 View ?

我试试 sap.ui.core.Core().byId("<name of view>")但它返回 undefined .

最佳答案

您可以使用以下方法实例化另一个 View :

var view = sap.ui.jsview("<name of view>");

如果您使用不同的 View 类型,您可以从 here 中选择必要的功能.

为了避免多次实例化,你可以这样做:

var view = sap.ui.getCore().byId("id");

if (view === undefined) {
view = sap.ui.jsview("id", "<name of view>");
}

参见 this有关 View 定义/实例化和 ID 的更多详细信息。

关于sapui5 - 如何在 Controller 外检索 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24267621/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com