简体   繁体   English

如何在SAPUI5中获取视图引用?

[英]how to get view references in SAPUI5?

Let's say I have my routes defined in my manifest.json like this 假设我在我的manifest.json文件中定义了这样的路由

rootView: "sap.ui.core.sample.TargetsStandalone.targetsApp.view.App",
        routing: {
            config: {
                targetsClass: "sap.m.routing.Targets",
                viewPath: "sap.ui.core.sample.TargetsStandalone.targetsApp.view",
                controlId: "rootControl",
                controlAggregation: "pages",
                viewType: "XML"
            },
            targets: {
                page1: {
                    viewName: "View1",
                    viewLevel: 0
                },
                page2: {
                    viewName: "View2",
                    viewLevel: 1
                }
            }
        }

Is there a way to retrieve the view references from the component(getOwnerComponent). 有没有一种方法可以从组件(getOwnerComponent)中检索视图引用。 What I want to do is, on the first controller I want to get a reference of label on "View2". 我想做的是,在第一个控制器上,我想在“ View2”上获取标签的引用。 It seems like there is no reference to the second view until I navigate to it. 在我导航到第二个视图之前,似乎没有引用它。 Is there a way to get the a reference to another view and its elements before I navigate to it? 在导航到另一个视图及其元素之前,有没有办法得到它的引用?

When you navigate to a view, the runtime instantiate it. 导航到视图时,运行时将其实例化。 Before that, there is no view. 在此之前,没有任何观点。 You can even see in the network trace how the XML file of certain view is downloaded once you navigate to it for the first time, but not before. 您甚至可以在网络跟踪中看到第一次(但不是第一次)导航到某个视图的XML文件后如何下载该视图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM