mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-05-20 21:49:14 +08:00
[improvement] Area: optimize performance (#1055)
This commit is contained in:
parent
353b8288d4
commit
97476fec76
@ -57,11 +57,10 @@
|
|||||||
|
|
||||||
&__item {
|
&__item {
|
||||||
padding: 0 5px;
|
padding: 0 5px;
|
||||||
color: @gray-dark;
|
color: @text-color;
|
||||||
|
|
||||||
&--selected {
|
&--selected {
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: @text-color;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&--disabled {
|
&--disabled {
|
||||||
|
@ -33,13 +33,6 @@ VantComponent({
|
|||||||
columns: []
|
columns: []
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
|
||||||
displayColumns() {
|
|
||||||
const { columns = [], columnsNum } = this.data;
|
|
||||||
return columns.slice(0, +columnsNum);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
value(value) {
|
value(value) {
|
||||||
this.code = value;
|
this.code = value;
|
||||||
@ -68,7 +61,8 @@ VantComponent({
|
|||||||
|
|
||||||
onChange(event: Weapp.Event) {
|
onChange(event: Weapp.Event) {
|
||||||
const { value } = event.detail;
|
const { value } = event.detail;
|
||||||
const { pickerValue, displayColumns } = this.data;
|
const { pickerValue } = this.data;
|
||||||
|
const displayColumns = this.getDisplayColumns();
|
||||||
const index = pickerValue.findIndex(
|
const index = pickerValue.findIndex(
|
||||||
(item, index) => item !== value[index]
|
(item, index) => item !== value[index]
|
||||||
);
|
);
|
||||||
@ -159,7 +153,8 @@ VantComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
getValues() {
|
getValues() {
|
||||||
const { displayColumns = [], pickerValue = [] } = this.data;
|
const { pickerValue = [] } = this.data;
|
||||||
|
const displayColumns = this.getDisplayColumns();
|
||||||
return displayColumns
|
return displayColumns
|
||||||
.map((option, index) => option[pickerValue[index]])
|
.map((option, index) => option[pickerValue[index]])
|
||||||
.filter(value => !!value);
|
.filter(value => !!value);
|
||||||
@ -201,6 +196,11 @@ VantComponent({
|
|||||||
reset() {
|
reset() {
|
||||||
this.code = '';
|
this.code = '';
|
||||||
this.setValues();
|
this.setValues();
|
||||||
|
},
|
||||||
|
|
||||||
|
getDisplayColumns() {
|
||||||
|
const { columns = [], columnsNum } = this.data;
|
||||||
|
return columns.slice(0, +columnsNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
class="van-picker__columns"
|
class="van-picker__columns"
|
||||||
>
|
>
|
||||||
<picker-view-column
|
<picker-view-column
|
||||||
wx:for="{{ displayColumns }}"
|
wx:if="{{ rowIndex < columnsNum }}"
|
||||||
|
wx:for="{{ columns }}"
|
||||||
wx:for-item="row"
|
wx:for-item="row"
|
||||||
wx:for-index="rowIndex"
|
wx:for-index="rowIndex"
|
||||||
wx:key="rowIndex"
|
wx:key="rowIndex"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
function isArray(obj) {
|
function isArray(array) {
|
||||||
return obj && obj.constructor === 'Array';
|
return array && array.constructor === 'Array';
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.isArray = isArray;
|
module.exports.isArray = isArray;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user