mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-24 18:36:51 +08:00
feat: migrate Area component
This commit is contained in:
parent
f956d1ab3b
commit
789a2fda1e
@ -67,4 +67,5 @@ module.exports = [
|
|||||||
'image-preview',
|
'image-preview',
|
||||||
'index-bar',
|
'index-bar',
|
||||||
'index-anchor',
|
'index-anchor',
|
||||||
|
'area',
|
||||||
];
|
];
|
||||||
|
@ -29,6 +29,7 @@ Vant 遵循 [Semver](https://semver.org/lang/zh-CN/) 语义化版本规范。
|
|||||||
- ActionSheet
|
- ActionSheet
|
||||||
- Calendar
|
- Calendar
|
||||||
- Dialog
|
- Dialog
|
||||||
|
- ImagePreview
|
||||||
- Notify
|
- Notify
|
||||||
- Popup
|
- Popup
|
||||||
- ShareSheet
|
- ShareSheet
|
||||||
|
@ -10,21 +10,6 @@ function isOverseaCode(code) {
|
|||||||
return code[0] === '9';
|
return code[0] === '9';
|
||||||
}
|
}
|
||||||
|
|
||||||
function pickSlots(instance, keys) {
|
|
||||||
const { $slots, $scopedSlots } = instance;
|
|
||||||
const scopedSlots = {};
|
|
||||||
|
|
||||||
keys.forEach((key) => {
|
|
||||||
if ($scopedSlots[key]) {
|
|
||||||
scopedSlots[key] = $scopedSlots[key];
|
|
||||||
} else if ($slots[key]) {
|
|
||||||
scopedSlots[key] = () => $slots[key];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return scopedSlots;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default createComponent({
|
export default createComponent({
|
||||||
props: {
|
props: {
|
||||||
...pickerProps,
|
...pickerProps,
|
||||||
@ -47,6 +32,8 @@ export default createComponent({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
emits: ['change', 'confirm'],
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
code: this.value,
|
code: this.value,
|
||||||
@ -78,6 +65,13 @@ export default createComponent({
|
|||||||
county: this.columnsPlaceholder[2] || '',
|
county: this.columnsPlaceholder[2] || '',
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
pickerSlots() {
|
||||||
|
return ['title', 'columns-top', 'columns-bottom'].reduce((slots, key) => {
|
||||||
|
slots[key] = this.$slots[key];
|
||||||
|
return slots;
|
||||||
|
}, {});
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
@ -88,7 +82,9 @@ export default createComponent({
|
|||||||
|
|
||||||
areaList: {
|
areaList: {
|
||||||
deep: true,
|
deep: true,
|
||||||
handler: 'setValues',
|
handler() {
|
||||||
|
this.setValues();
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
columnsNum() {
|
columnsNum() {
|
||||||
@ -297,14 +293,9 @@ export default createComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const on = {
|
|
||||||
...this.$listeners,
|
|
||||||
change: this.onChange,
|
|
||||||
confirm: this.onConfirm,
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Picker
|
<Picker
|
||||||
|
v-slots={this.pickerSlots}
|
||||||
ref="picker"
|
ref="picker"
|
||||||
class={bem()}
|
class={bem()}
|
||||||
showToolbar
|
showToolbar
|
||||||
@ -317,12 +308,8 @@ export default createComponent({
|
|||||||
visibleItemCount={this.visibleItemCount}
|
visibleItemCount={this.visibleItemCount}
|
||||||
cancelButtonText={this.cancelButtonText}
|
cancelButtonText={this.cancelButtonText}
|
||||||
confirmButtonText={this.confirmButtonText}
|
confirmButtonText={this.confirmButtonText}
|
||||||
scopedSlots={pickSlots(this, [
|
onChange={this.onChange}
|
||||||
'title',
|
onConfirm={this.onConfirm}
|
||||||
'columns-top',
|
|
||||||
'columns-bottom',
|
|
||||||
])}
|
|
||||||
{...{ on }}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -331,10 +331,10 @@ module.exports = {
|
|||||||
// path: 'address-list',
|
// path: 'address-list',
|
||||||
// title: 'AddressList 地址列表',
|
// title: 'AddressList 地址列表',
|
||||||
// },
|
// },
|
||||||
// {
|
{
|
||||||
// path: 'area',
|
path: 'area',
|
||||||
// title: 'Area 省市区选择',
|
title: 'Area 省市区选择',
|
||||||
// },
|
},
|
||||||
// {
|
// {
|
||||||
// path: 'card',
|
// path: 'card',
|
||||||
// title: 'Card 商品卡片',
|
// title: 'Card 商品卡片',
|
||||||
@ -665,10 +665,10 @@ module.exports = {
|
|||||||
// path: 'address-list',
|
// path: 'address-list',
|
||||||
// title: 'AddressList',
|
// title: 'AddressList',
|
||||||
// },
|
// },
|
||||||
// {
|
{
|
||||||
// path: 'area',
|
path: 'area',
|
||||||
// title: 'Area',
|
title: 'Area',
|
||||||
// },
|
},
|
||||||
// {
|
// {
|
||||||
// path: 'card',
|
// path: 'card',
|
||||||
// title: 'Card',
|
// title: 'Card',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user