uview-plus 3.3.72 → 3.3.74

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.
package/changelog.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 3.3.74(2025-03-06)
2
+ fix: CateTab语法问题
3
+
4
+ ## 3.3.73(2025-03-06)
5
+ feat: CateTab新增v-model:current属性
1
6
  ## 3.3.72(2025-02-28)
2
7
  feat: tabs组件支持icon图标及插槽
3
8
 
@@ -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="[current == index ? 'u-cate-tab__item-active' : '']"
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
+ },
61
+ current: {
62
+ type: Number,
63
+ default: 0
60
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
- current: 0, // 预设当前项的值
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.current) return;
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.current = index;
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.current = index;
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
@@ -2,7 +2,7 @@
2
2
  "id": "uview-plus",
3
3
  "name": "uview-plus",
4
4
  "displayName": "零云®uview-plus3.0重磅发布,全面的Vue3鸿蒙移动组件库。",
5
- "version": "3.3.72",
5
+ "version": "3.3.74",
6
6
  "description": "零云®uview-plus已兼容vue3,全面的组件和便捷的工具会让您信手拈来,如鱼得水",
7
7
  "keywords": [
8
8
  "uview",