出于用户体验原因,如何使按钮看起来已启用,但它应该被禁用

How to make a button seem enabled for UX reasons, however it is supposed to be disabled

标题好像有点乱,我解释一下。

按钮确实有 属性 .setEnabled("false"),在这种情况下它将被禁用,即您将无法单击它。但是,出于美观原因,我希望它可以单击(就像 .setEnabled("true") 已被调用一样)但要禁用该功能。如果用户填写了特定的表格,他们可以提交,否则他们会收到一条错误消息。

我试过的:这个东西 Button.setEnabled(false)

sap.ui.getCore().byId("Button").setEnabled(false)

预期结果:使其可点击,但如果未填写表单,则应出现错误消息。

实际结果:无法点击的按钮

您应该按照 Fiori UX guidance. If you in addition need some checks to be performed across several form fields, you can then handle the button press to validate the form fields individual status and the combination of its values to raise errors accordingly as explained in the Fiori UX guidance for forms.

中的说明添加表单字段验证,而不是禁用该按钮

禁用按钮仅适用于按下按钮没有意义的情况(例如,您未处于编辑模式)并且您需要向最终用户说明这一点。在所有其他情况下,您保持启用状态并显示正确的错误消息。