mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[new feature] Area: add is-oversea-code prop (#4163)
This commit is contained in:
parent
112839984d
commit
89a980466f
@ -55,6 +55,7 @@ Set `columns-num` with 2, you'll have a 2 level picker.
|
||||
| visible-item-count | Count of visible columns | `number` | `5` |
|
||||
| confirm-button-text | Text of confirm button | `string` | `Confirm` |
|
||||
| cancel-button-text | Text of cancel button | `string` | `Cancel` |
|
||||
| is-oversea-code | The method to validate oversea code | `() => boolean` | - |
|
||||
|
||||
### Events
|
||||
|
||||
|
@ -54,6 +54,7 @@ Vue.use(Area);
|
||||
| visible-item-count | 可见的选项个数 | `number` | `5` | - |
|
||||
| confirm-button-text | 确认按钮文字 | `string` | `确认` | 1.5.3 |
|
||||
| cancel-button-text | 取消按钮文字 | `string` | `取消` | 1.5.3 |
|
||||
| is-oversea-code | 根据`code`校验海外地址,海外地址会划分至单独的分类 | `() => boolean` | - | 2.1.4 |
|
||||
|
||||
### Events
|
||||
|
||||
|
@ -4,6 +4,10 @@ import { pickerProps } from '../picker/shared';
|
||||
|
||||
const [createComponent, bem] = createNamespace('area');
|
||||
|
||||
function isOverseaCode(code) {
|
||||
return code[0] === '9';
|
||||
}
|
||||
|
||||
export default createComponent({
|
||||
props: {
|
||||
...pickerProps,
|
||||
@ -15,6 +19,10 @@ export default createComponent({
|
||||
columnsNum: {
|
||||
type: [Number, String],
|
||||
default: 3
|
||||
},
|
||||
isOverseaCode: {
|
||||
type: Function,
|
||||
default: isOverseaCode
|
||||
}
|
||||
},
|
||||
|
||||
@ -81,7 +89,7 @@ export default createComponent({
|
||||
|
||||
if (code) {
|
||||
// oversea code
|
||||
if (code[0] === '9' && type === 'city') {
|
||||
if (this.isOverseaCode(code) && type === 'city') {
|
||||
code = '9';
|
||||
}
|
||||
|
||||
@ -97,7 +105,7 @@ export default createComponent({
|
||||
const list = this.getList(type, code.slice(0, compareNum - 2));
|
||||
|
||||
// oversea code
|
||||
if (code[0] === '9' && type === 'province') {
|
||||
if (this.isOverseaCode(code) && type === 'province') {
|
||||
compareNum = 1;
|
||||
}
|
||||
|
||||
@ -163,7 +171,7 @@ export default createComponent({
|
||||
const names = values.map(item => item.name);
|
||||
|
||||
area.code = values[values.length - 1].code;
|
||||
if (area.code[0] === '9') {
|
||||
if (this.isOverseaCode(area.code)) {
|
||||
area.country = names[1] || '';
|
||||
area.province = names[2] || '';
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user