可编辑为false时UI5显示占位符
UI5 display placeholder when editable is false
我正在使用 editable=false 的输入标签,但问题是占位符不可见。
输入字段上有一个点击事件。
有没有办法显示占位符。
假设您的字段名为“email”,那么您在 i18n 文件中写入占位符文本:
placeholder.email=Enter Email
在您的 XML 文件中使用 Expression Binding
<Input type="Text" placeholder="{i18n>placeholder.email}" value="{= ${model>/email} === '' ? ${i18n>placeholder.email} : ${model>/email}}" editable="false"/>
如果值(model>/email
)为空,该值将是占位符文本(i18n>placeholder.email
)。
表达式绑定
{= ${model>/email} === '' ? ${i18n>placeholder.email} : ${model>/email}}
占位符可以帮助用户输入数据。
The placeholder [...] is a short hint (a word or short phrase) to help the user with data entry.
(Source)
如果输入字段一开始就不可编辑,则不应依赖占位符。相反,请考虑使用 sap.m.Label
作为替代方案。
Avoid using the placeholder attribute as an alternative to a label. [...] Labels are necessary to indicate the meaning of the form fields when the placeholders are no longer visible. (Source)
占位符不是标签的替代品。
我正在使用 editable=false 的输入标签,但问题是占位符不可见。 输入字段上有一个点击事件。 有没有办法显示占位符。
假设您的字段名为“email”,那么您在 i18n 文件中写入占位符文本:
placeholder.email=Enter Email
在您的 XML 文件中使用 Expression Binding
<Input type="Text" placeholder="{i18n>placeholder.email}" value="{= ${model>/email} === '' ? ${i18n>placeholder.email} : ${model>/email}}" editable="false"/>
如果值(model>/email
)为空,该值将是占位符文本(i18n>placeholder.email
)。
表达式绑定
{= ${model>/email} === '' ? ${i18n>placeholder.email} : ${model>/email}}
占位符可以帮助用户输入数据。
The placeholder [...] is a short hint (a word or short phrase) to help the user with data entry. (Source)
如果输入字段一开始就不可编辑,则不应依赖占位符。相反,请考虑使用 sap.m.Label
作为替代方案。
Avoid using the placeholder attribute as an alternative to a label. [...] Labels are necessary to indicate the meaning of the form fields when the placeholders are no longer visible. (Source)
占位符不是标签的替代品。