EFolderPicker 目录选择
示例与代码
选择工作目录
设置初始目录
禁用选择
浏览
打开文件
属性
accessibleNamestring辅助技术读取的名称;建议为无文字控件设置可读名称。
placeholderTextappendComponentComponent自定义输入附加区或列表尾部的 Component 插槽;null 使用默认内容。 委托上下文见本页示例。
展开默认值
ETextButton { minHeight: 0 implicitWidth: 34 iconSource: EIcons.ELLIPSIS objectName: "filePickerBrowse" height: control.height accessibleName: EControlConfig.textFor(control, "PickerBrowse", ELocale.texts) onClicked: control.open() }clearIconint组件使用的图标。
EIcons.*
0(无图标)
EIcons.CIRCLE_XMARKclearablebool显示清除操作;评分中允许再次点击当前分数清零。
truedialogTitlestring原生对话框标题与输入占位文字。
展开默认值
EControlConfig.textFor(control, mode === "save" ? "PickerSaveFile" : mode === "folder" ? "PickerSelectFolder" : "SelectFiles", ELocale.texts)enabledbool是否允许交互;false 时控件禁用。
truefolderurl对话框的初始目录 URL。
""fontfont字体配置,控制字体、字号及文字样式。
常用字段:
family、pixelSize、pointSize
bold、italic、weight
underline、strikeout
letterSpacing、wordSpacing
应用字体formattervar格式化回调,把当前值转换为显示文字。
nullheightreal组件尺寸,单位为像素;可绑定父布局尺寸。
implicitHeightmodestring选择模式:open 打开文件、save 选择保存位置、folder 选择目录。
open / save / folder
"folder"multiplebool打开文件时允许多选;保存和目录模式仍为单选。
falsenameFiltersvar原生文件对话框的过滤器列表,例如 Text files (*.txt)。
["All files (*)"]parservar输入解析函数,把显示文字转换为底层值。
nullpasswordVisiblebool密码是否以明文显示。
falseprefixComponentComponent自定义前缀的 Component 插槽;null 使用默认内容。 委托上下文见本页示例。
nullprefixIconint组件使用的图标。
EIcons.*
0(无图标)
继承默认值prependComponentComponent自定义输入前置区的 Component 插槽;null 使用默认内容。 委托上下文见本页示例。
nullshowPasswordbool启用密码输入及密码显示切换。
falseshowWordLimitbool显示当前字数与长度上限。
falsesizeint文字尺寸。
EStyle.SmallEStyle.MediumEStyle.Large
EControlConfig.sizeFor(control)styleTypeint语义配色风格。
EStyle.DefaultEStyle.PrimaryEStyle.SuccessEStyle.InfoEStyle.WarningEStyle.Danger
EStyle.PrimarysuffixComponentComponent自定义后缀的 Component 插槽;null 使用默认内容。 委托上下文见本页示例。
nullsuffixIconint组件使用的图标。
EIcons.*
0(无图标)
继承默认值textColorcolor文字颜色。
展开默认值
EPaletteManager.StatePalette.defaultTextColor( EPaletteManager.createStateObject(this, EStyle.TextColor) .setDark(ETheme.dark) .setEnabled(control.enabled) )validateEventbool值变化时是否向所属表单派发校验请求。
truevalidationMessagestring校验结果说明或外部错误文字。
""validationStateint输入校验状态。
EValidationState.NoneEValidationState.SuccessEValidationState.WarningEValidationState.Error
EValidationState.Nonevaluevar当前选择;单选为文件 URL,多选为文件 URL 数组。
""visiblebool是否显示组件。
truewidthreal组件尺寸,单位为像素;可绑定父布局尺寸。
implicitWidthdialogvar只读延迟创建的原生对话框;创建前为 null。
字段:
alignCenter, draggable, overflow
由运行时计算hasValidationErrorbool只读当前校验状态是否为 Error。
由运行时计算lastErrorstring只读最近一次选择失败的原因代码;成功或清空后为空。
由运行时计算popupVisiblebool只读原生选择对话框是否可见。
由运行时计算selectedUrlsvar只读将当前选择统一转换为 URL 数组。
由运行时计算wordCountint只读当前输入字符数量。
由运行时计算showPasswordStrengthbool聚焦密码输入时显示强度与规则检查。
falsepasswordRulesvar密码规则数组;每项包含 label 及 minLength 或 pattern。
展开默认值
[ {label: ELocale.texts.PasswordLength, minLength: 8}, {label: ELocale.texts.PasswordUppercase, pattern: /[A-Z]/}, {label: ELocale.texts.PasswordLowercase, pattern: /[a-z]/}, {label: ELocale.texts.PasswordNumber, pattern: /[0-9]/}, {label: ELocale.texts.PasswordSymbol, pattern: /[^A-Za-z0-9]/} ]passwordStrengthreal只读通过规则的比例,范围为 0 到 1。
展开默认值
passwordRequirements.length ? passwordRequirements.filter(function(rule) { return rule.passed }).length / passwordRequirements.length : 0passwordRequirementsvar只读包含 label 与 passed 的规则检查结果。
展开默认值
Array.isArray(passwordRules) ? passwordRules.map(function(rule) { let passed = false try { if (rule && rule.minLength !== undefined) passed = text.length >= Number(rule.minLength) else if (rule && rule.pattern) { const expression = new RegExp(rule.pattern) passed = expression.test(text) } } catch (error) { passed = false } return {label: rule && rule.label ? String(rule.label) : "", passed: passed} }) : []信号
cleared()使用清空操作清除内容后触发。
formatFailed(string message)输入格式化失败时触发,message 为失败原因。
rejected()用户取消文件选择时触发。
picked(var value)选定值后触发,value 为选中的值。
selectionRejected(string reason)所选路径不符合限制时触发,reason 为拒绝原因。
方法
close()关闭组件的面板或弹窗。
clear()清空组件当前内容或选择。
open()打开组件的面板或弹窗。