Skip to content

Commit 1be4c61

Browse files
committed
二级联动滚动优化
1 parent b70bfd4 commit 1be4c61

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

src/app.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"pages": [
3-
"pages/test/main",
4-
"pages/demo/main"
3+
"pages/demo/main",
4+
"pages/test/main"
55
],
66
"window": {
77
"backgroundTextStyle": "light",

src/mpvue-picker/mpvuePicker.vue

+15-14
Original file line numberDiff line numberDiff line change
@@ -268,23 +268,24 @@ export default {
268268
if (this.deepLength === 2) {
269269
let pickerValueArray = this.pickerValueArray;
270270
let changeValue = e.mp.detail.value;
271-
let pickerValueMulTwoTwo = [];
272-
// 第一列滚动第二列数据更新
273-
for (
274-
let i = 0, length = pickerValueArray[changeValue[0]].children.length;
275-
i < length;
276-
i++
277-
) {
278-
pickerValueMulTwoTwo.push(
279-
pickerValueArray[changeValue[0]].children[i]
280-
);
281-
}
282-
// 第一级不等于第二级
271+
// 处理第一列滚动
283272
if (changeValue[0] !== this.pickerValue[0]) {
284-
// 第二列初始化为 1
273+
let pickerValueMulTwoTwo = [];
274+
// 第一列滚动第二列数据更新
275+
for (
276+
let i = 0,
277+
length = pickerValueArray[changeValue[0]].children.length;
278+
i < length;
279+
i++
280+
) {
281+
pickerValueMulTwoTwo.push(
282+
pickerValueArray[changeValue[0]].children[i]
283+
);
284+
}
285+
this.pickerValueMulTwoTwo = pickerValueMulTwoTwo;
286+
// 第二列初始化为 0
285287
changeValue[1] = 0;
286288
}
287-
this.pickerValueMulTwoTwo = pickerValueMulTwoTwo;
288289
this.pickerValue = changeValue;
289290
} else if (this.deepLength === 3) {
290291
let pickerValueArray = this.pickerValueArray;

0 commit comments

Comments
 (0)