uview-plus 3.3.72 → 3.3.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
scroll-y scroll-with-animation :scroll-top="scrollTop"
|
|
6
6
|
:scroll-into-view="itemId">
|
|
7
7
|
<view v-for="(item, index) in tabList" :key="index" class="u-cate-tab__item"
|
|
8
|
-
:class="[
|
|
8
|
+
:class="[innerCurrent == index ? 'u-cate-tab__item-active' : '']"
|
|
9
9
|
@tap.stop="swichMenu(index)">
|
|
10
10
|
<slot name="tabItem" :item="item">
|
|
11
11
|
</slot>
|
|
@@ -57,18 +57,23 @@
|
|
|
57
57
|
itemKeyName: {
|
|
58
58
|
type: String,
|
|
59
59
|
default: 'name'
|
|
60
|
-
}
|
|
60
|
+
},
|
|
61
|
+
current: : {
|
|
62
|
+
type: Number,
|
|
63
|
+
default: 0
|
|
64
|
+
},
|
|
61
65
|
},
|
|
62
66
|
watch: {
|
|
63
67
|
tabList() {
|
|
64
68
|
this.getMenuItemTop()
|
|
65
69
|
}
|
|
66
|
-
},
|
|
70
|
+
},
|
|
71
|
+
emits: ['update:current'],
|
|
67
72
|
data() {
|
|
68
73
|
return {
|
|
69
74
|
scrollTop: 0, //tab标题的滚动条位置
|
|
70
75
|
oldScrollTop: 0,
|
|
71
|
-
|
|
76
|
+
innerCurrent: 0, // 预设当前项的值
|
|
72
77
|
menuHeight: 0, // 左边菜单的高度
|
|
73
78
|
menuItemHeight: 0, // 左边菜单item的高度
|
|
74
79
|
itemId: '', // 栏目右边scroll-view用于滚动的id
|
|
@@ -79,8 +84,16 @@
|
|
|
79
84
|
timer: null, // 定时器
|
|
80
85
|
}
|
|
81
86
|
},
|
|
82
|
-
onMounted() {
|
|
87
|
+
onMounted() {
|
|
88
|
+
this.innerCurrent = this.current;
|
|
89
|
+
this.leftMenuStatus(this.innerCurrent);
|
|
83
90
|
this.getMenuItemTop()
|
|
91
|
+
},
|
|
92
|
+
watch: {
|
|
93
|
+
current(nval) {
|
|
94
|
+
this.innerCurrent = nval;
|
|
95
|
+
this.leftMenuStatus(index);
|
|
96
|
+
}
|
|
84
97
|
},
|
|
85
98
|
methods: {
|
|
86
99
|
// 点击左边的栏目切换
|
|
@@ -88,12 +101,13 @@
|
|
|
88
101
|
if(this.arr.length == 0) {
|
|
89
102
|
await this.getMenuItemTop();
|
|
90
103
|
}
|
|
91
|
-
if (index == this.
|
|
104
|
+
if (index == this.innerCurrent) return;
|
|
92
105
|
this.scrollRightTop = this.oldScrollTop;
|
|
93
106
|
this.$nextTick(function(){
|
|
94
107
|
this.scrollRightTop = this.arr[index];
|
|
95
|
-
this.
|
|
96
|
-
this.leftMenuStatus(index);
|
|
108
|
+
this.innerCurrent = index;
|
|
109
|
+
this.leftMenuStatus(index);
|
|
110
|
+
this.$emit('update:current', index);
|
|
97
111
|
})
|
|
98
112
|
},
|
|
99
113
|
// 获取一个目标元素的高度
|
|
@@ -126,14 +140,15 @@
|
|
|
126
140
|
}).observe('#item' + index, res => {
|
|
127
141
|
if (res.intersectionRatio > 0) {
|
|
128
142
|
let id = res.id.substring(4);
|
|
129
|
-
this.leftMenuStatus(id);
|
|
143
|
+
this.leftMenuStatus(id);
|
|
130
144
|
}
|
|
131
145
|
})
|
|
132
146
|
})
|
|
133
147
|
},
|
|
134
148
|
// 设置左边菜单的滚动状态
|
|
135
149
|
async leftMenuStatus(index) {
|
|
136
|
-
this.
|
|
150
|
+
this.innerCurrent = index;
|
|
151
|
+
this.$emit('update:current', index);
|
|
137
152
|
// 如果为0,意味着尚未初始化
|
|
138
153
|
if (this.menuHeight == 0 || this.menuItemHeight == 0) {
|
|
139
154
|
await this.getElRect('u-cate-tab__menu-scroll-view', 'menuHeight');
|
package/package.json
CHANGED