Region Selection
WdRegion
Applicable Scenarios
for selecting administrative divisions at various levels (provinces, cities, districts)
Basic Capabilities Description
Binding the "Region" Field
After the form container is bound to a data model, the "Region" field in the model is automatically rendered as a region selection component, enabling the selection and input of region information.
Extended Scenarios Description
Retrieving Selected Region Codes via the Region Selection Component
Best Practices:
Obtain the selected region information through the output parameters of the region selection component's change event.
Configuration Method:
Region Selection Component: The component's change event can be used to obtain the code of the currently selected region.
Parameter Format
- The province-level code can be obtained from event.detail.result[0].code
- The province and city code can be obtained from event.detail.result[1].code
- The province, city, and district code can be obtained from event.detail.result[2].code
- The complete array-type output parameters can be obtained from event.detail.value
- Note: To accommodate future street codes, the current output parameter uses a 12-digit format.
Operation Example: Configure the change (value change) event of the Region Selection component to trigger a pop-up action. Enter the expression event.detail.result[0].code in the pop-up content to display the province-level code of the selected region in a pop-up.
The event configuration method is as follows
Runtime result is as follows
Other Scenario Practices
Refer to the Form Scenario Practice Guide to learn about various supported scenarios and implementation solutions for forms.
Example
Interactive Preview
Component Input State
Style API Example
#wd-page-root .wd-form-item .wd-region-region {
border-color: cyan;
color: cyan;
background-color: black;
border-width: 2px;
border-radius: 6px;
}
Properties
External properties received by the component
Property Name | Property Identifier | Type | Description |
---|
显示标题 | labelVisible | boolean | Default value: true |
标题对齐 | labelAlign | string | 表单场景下默认会跟随表单容器的标题对齐配置 |
标题换行 | labelWrap | boolean | 如果标题内容过长关闭时只显示一行、溢出省略;开启时换行展示。表单场景下默认会跟随表单容器的标题换行配置 |
标题位置 | layout | string | 设置标题在表单组件的展示位置,表单场景下默认会跟随表单容器的标题的位置配置 |
标题宽度 | labelWidth | string | 表单场景下默认会跟随表单容器的标题宽度配置 |
标题提示 | labelTips | string | 配置标题的工具提示内容 |
显示清空按钮 | clearable | boolean | 开启后提供快捷清空按钮 Default value: true |
前缀文字 | before | string | 表单输入框显示前缀文字,表单提交场景下前缀文字会作为表单内容一起提交到数据模型中 |
后缀文字 | after | string | 表单输入框显示后缀文字,表单提交场景下后缀文字会作为表单内容一起提交到数据模型中 |
前缀图标类型 | prefixType | string | 选择图标的类型 Example: "" |
前缀图标 | prefixIcon | string | 表单输入框中展示前图标 Example: "success" |
前缀图标 | prefixSrc | string | 设置自定义图标地址 |
后缀图标类型 | suffixType | string | 选择图标的类型 Example: "fixed" |
后缀图标 | suffixIcon | string | 表单输入框中展示后图标 Example: "success" |
后缀图标 | suffixSrc | string | 设置自定义图标地址 |
下方提示 | extra | string | 配置后提示内容常显在输入框下方 |
移动端显示下划线 | borderedH5 | boolean | 关闭后移动端不显示底部下划线 Default value: true |
PC端显示输入边框 | borderedPc | boolean | 关闭后PC端不显示输入边框 Default value: true |
状态 | status | string | Example: "edit" |
必填 | required | boolean | |
必填标识 | requiredFlag | boolean | 启用后,组件若要求必填,则会显示必填星号标记 Default value: true |
必填校验提示 | requiredMsg | string | Example: "该项为必填项" |
绑定字段 | name | string | 表单字段的Key值,用于提交数据时,匹配数据模型字段标识。表单内需保证唯一。 |
标题内容 | label | string | Example: "地区" |
地区类型 | regionType | string | Default value: "levelThree" |
选中地区 | value | string | 省市区之间请用,分隔 |
占位文字 | placeholder | string | Example: "请选择" |
PC端组件尺寸 | size | string | 尺寸配置仅对PC端生效,表单场景下默认会跟随表单容器的组件尺寸配置 |
Events
Events exposed by the component. You can listen to component events to trigger external actions
Event Name | Event Code | Event Output Parameters event.detail | Applicable Scenarios | Description |
---|
值改变 | change | object
| Compatible with all platforms | 用户修改组件值时触发 |
Property API
Through the Property API, you can access the internal state and property values of components. You can access internal values using$w.componentId.propertyName
, such as $w.input1.value
. For details, please refer to Property API
Read-only Property Name | Property Identifier | Type | Description |
---|
绑定字段 | name | string | 表单字段的Key值,用于提交数据时,匹配数据模型字段标识。表单内需保证唯一。 |
标题内容 | label | string | |
输入值 | value | string | |
前缀文字 | before | string | 表单输入框显示前缀文字,表单提交场景下前缀文字会作为表单内容一起提交到数据模型中 |
后缀文字 | after | string | 表单输入框显示后缀文字,表单提交场景下后缀文字会作为表单内容一起提交到数据模型中 |
必填 | required | boolean | |
是否展示 | visible | boolean | 组件是否展示 |
是否禁用 | disabled | boolean | 组件是否禁用 |
是否只读 | readOnly | boolean | 组件是否只读 |
Method API
Through the Method API, you can programmatically trigger internal methods of components, such as submitting forms, displaying popups, etc. You can call component methods using $w.componentId.methodName
, such as $w.form1.submit()
Method Name | Method Identifier | Parameters | Method Description |
---|
设置值 | setValue | string 值 | 通过 $w.id1.setValue("weda") 设置组件值 |
设置显隐 | setVisible | boolean 显示 | 通过 $w.id1.setVisible(false) 设置组件为隐藏 |
设置禁用 | setDisabled | boolean 禁用 | 通过 $w.id1.setDisabled(true) 设置组件为禁用 |
清空值 | clearValue | 通过 $w.id1.clearValue() 清空组件值 | |
设置只读 | setReadOnly | boolean 只读 | 通过 $w.id1.setReadOnly(true) 设置组件为只读 |
触发校验 | handleValidate | 通过 $w.id1.handleValidate() 校验组件值 | |
清除校验 | clearValidate | 通过 $w.id1.clearValidate() 清除组件校验 |
Style API
Through the Style API, you can override the styles of internal elements in components to achieve customization. For example, in the low-code editor, you can write styles for all button components using #wd-page-root .wd-btn
, and control individual component styles with :scope
. For detailed instructions, please refer toStyle API
Name | Class Name | Description and Examples |
---|
根元素 | .wd-region-root | 组件最外层元素
|
H5 端根元素 | .wd-h5-region-root | 可设定 H5 端的根元素样式
|
PC 端根元素 | .wd-pc-region-root | 可设定 PC 端的根元素样式
|
小程序端根元素 | .wd-mp-region-root | 可设定小程序端的根元素样式
|
组件标题样式 | .wd-region-root .wd-form-item-wrap__label | 组件标题元素
|
表单控件根节点样式 | .wd-region-root .wd-form-item-wrap__control | 设置表单控件根元素样式
|
编辑态-选择框样式 | .wd-region-root .wd-form-input-wrap | 组件边框、边距样式、背景色、字体大小、字体颜色等
|
编辑态-选择框样式(获取焦点) | .wd-region-root .wd-form-input-wrap.is-focused | 编辑态-选择框样式(获取焦点)
|
编辑态-占位文字样式 | .wd-region-root input::placeholder, .wd-region-root .weui-input__placeholder | 设置占位文字样式
|
编辑态-校验信息 | .wd-region-root .wd-g-text-error | 设置组件校验信息样式
|
提示文字 | .wd-region-root .wd-form-item__help-text | 设置组件提示文字样式
|
禁用态-选择框样式 | .wd-region-root .wd-form-input-wrap.is-disabled | 组件禁用样式
|
只读态-表单值样式 | .wd-region-root .wd-form-item__readonly-value | 设置组件只读状态
|
前缀文字样式 | .wd-region-root .wd-form-input-group__addon-left | 设置组件前缀文字样式
|
后缀文字样式 | .wd-region-root .wd-form-input-group__addon-right | 设置组件后缀文字样式
|
Version Changes
- Property changes
- Style changes
- widget api changes