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