如何清除文本区域

Niv*_*vin 0 sapui5

XML视图

<TextArea id="message"
  maxLength="100"
  width="100%"
  valueLiveUpdate="true"
  showExceededText="false"
  placeholder="Type here.."
  required="true"
/>
Run Code Online (Sandbox Code Playgroud)

调节器

onInit: function() {
  // ...
  this.getView().byId("message").setText("");
},
Run Code Online (Sandbox Code Playgroud)

在这里,我尝试了两个命令来清除文本区域值.但是得到了错误

  • this.getView().byId("message").setText("");

    TypeError:this.getView(...).byId(...).setText不是函数

  • sap.ui.getCore().byId("message").setText("");

    TypeError:sap.ui.getCore(...).byId(...)未定义.

如何从JS中清除TextArea值?

Bog*_*ann 6

该控件sap.m.TextArea没有text属性,因此也没有这样的mutator和accessor.相反,可以通过属性设置文本值,value因为控件扩展了InputBase.

因此,该行应该是:

this.byId("message").setValue();
Run Code Online (Sandbox Code Playgroud)