小编use*_*184的帖子

UI5:如何访问在视图中定义的 html 元素?

我有一个带有此视图的 UIComponent:

<mvc:View controllerName="my.components.webmap.controller.Map"
   xmlns:mvc="sap.ui.core.mvc"
   xmlns="sap.m"
   xmlns:html="http://www.w3.org/1999/xhtml">
   <html:div id='myDiv' style='height:inherit'></html:div>
   <Button id="helloWorld" text="Say Hello" press=".onShowHello" />
</mvc:View>
Run Code Online (Sandbox Code Playgroud)

在视图控制器中,我可以从

this.getView().byId("helloWorld").sId
Run Code Online (Sandbox Code Playgroud)

但我无法使用该byId()方法获取 div 的 ID 。

<mvc:View controllerName="my.components.webmap.controller.Map"
   xmlns:mvc="sap.ui.core.mvc"
   xmlns="sap.m"
   xmlns:html="http://www.w3.org/1999/xhtml">
   <html:div id='myDiv' style='height:inherit'></html:div>
   <Button id="helloWorld" text="Say Hello" press=".onShowHello" />
</mvc:View>
Run Code Online (Sandbox Code Playgroud)

如何获取 div 的 ID 以访问该元素?我需要 div 的 ID,所以我可以向它附加一些额外的 3rd 方控件。

html javascript sapui5

3
推荐指数
1
解决办法
6807
查看次数

标签 统计

html ×1

javascript ×1

sapui5 ×1