fix: 完善移动端表单响应式布局

This commit is contained in:
jxxghp
2026-07-14 13:51:50 +08:00
parent cec9563963
commit d625d1ad46
3 changed files with 34 additions and 3 deletions
+17 -1
View File
@@ -24,6 +24,15 @@ function hasDisplayText(value: unknown): value is string | number {
return (typeof value === 'string' && value.trim().length > 0) || typeof value === 'number'
}
/**
* 判断录入控件模型中是否已有可展示的值。
*/
function hasInputValue(value: unknown) {
if (Array.isArray(value)) return value.length > 0
return value !== undefined && value !== null && value !== ''
}
/**
* 解析包装组件尚未声明的 Vue 布尔属性值。
*/
@@ -127,12 +136,19 @@ export function createResponsiveInputAdapter(component: Component, options: Resp
const { label: labelSlot, ...controlSlots } = slots
const labelContent = labelSlot?.({ label, props: { for: controlId } }) ?? String(label)
const disabled = isBooleanAttributeEnabled(attrs.disabled)
const isField = options.kind === 'field' || options.kind === 'multiline'
const isEmptyWithoutPlaceholder = isField
&& !hasInputValue(attrs.modelValue ?? attrs['model-value'])
&& !hasDisplayText(attrs.placeholder)
return h('div', {
class: [
'app-responsive-input',
`app-responsive-input--${options.kind}`,
{ 'app-responsive-input--disabled': disabled },
{
'app-responsive-input--disabled': disabled,
'app-responsive-input--empty': isEmptyWithoutPlaceholder,
},
rootClass,
],
style: rootStyle,