我想value通过value从另一个page或另一个输入区域取一个来设置文本。这是我的文本字段。我为尝试了多种组合this.byId("thisOne").,但没有用。
this.byId("thisOne").setValue("Some thing");
Run Code Online (Sandbox Code Playgroud)
其它的办法:
sap.ui.getCore().byId("thisOne")....
Run Code Online (Sandbox Code Playgroud)
文字元素:
<Text text="" id ="thisOne"/>
Run Code Online (Sandbox Code Playgroud)
我的XML文件:
<mvc:View
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m" controllerName="App.view.Take"
xmlns:l="sap.ui.layout"
xmlns:f="sap.ui.layout.form">
<Page showHeader="false">
<Label text="thisOne" />
<Input text="" id="thisOne" />
<Button type="Accept" text="Accept" ></Button>
<Button type="Reject" text="Reject" ></Button>
</Page>
</mvc:View>
Run Code Online (Sandbox Code Playgroud)
如果在XML视图中为控件显式指定ID,则实际ID会以XML视图的ID开头,例如Input控件的实际ID为“ __xmlview0--thisOne”。
最佳实践是使用XML视图的byId函数来获取其中包含的控件的ID。因此,例如,在连接到视图的控制器中(App.view.Take.controller.js针对您的情况),您可以执行以下操作:
this.getView().byId("thisOne").setValue("Some thing");