Address
地址控件
API
IAddressProps
| 参数 | 类型 | 说明 | 默认值 |
|---|---|---|---|
| maxDetailLen | number | 详细地址最大字符长度 | - |
| showAddress | boolean | 是否展示省市区地址选择 | - |
| placeholder | string | 输入提示文案 | - |
| limitLevel | ’COUNTRY’|‘PROVINCE’|‘CITY’|‘DISTRICT’|‘DISTRICT’|”DISTRICT” | 指定可选择的层级 | - |
数据结构
{ address: [ { id: "120000", name: "天津" }, { id: "120100", name: "天津市" }, { id: "120103", name: "河西区" }, { id: "12010300302", name: "桃园街道" }, ], // 地区选择 detail: "南开大学", //详细地址 postcode: "308945", //邮政编码}// address 默认为必填,detail 和 postcode 为选填API
自定义校验的例子
<Field name="address"> <Validations> <Validation validator="#{addressValidator}" /> </Validations></Field>import _ from 'lodash'
addressValidator = (rule, value, callback) => { if (!_.isEmpty(value)) { const { detail, postcode } = value if (detail && detail.length > 35) { callback('详细地址长度不能超过35个字符') } else if (!postcode) { callback('邮政编码不能为空') } } callback() }}用法
注意:当前例子为0.17.x 版本