uview-plus 3.3.7 → 3.3.9

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,33 @@
1
+ ## 3.3.9(2024-08-01)
2
+ fix: 优化获取nvue元素
3
+
4
+ feat: modal新增contentTextAlign设置文案对齐方式
5
+
6
+ fix: 修复NVUE下tabbar文字不显示 #458
7
+
8
+ feat: loading-page增加zIndex属性
9
+
10
+ fix: 相册在宽度较小时换行问题
11
+
12
+ feat: album相册增加自适应自动换行模式
13
+
14
+ feat: album相册增加图片尺寸单位prop
15
+
16
+ fix: 修复calendar日历月份居中
17
+
18
+ ## 3.3.8(2024-07-31)
19
+ feat: slider支持进度条任意位置触发按钮拖动
20
+
21
+ fix: 修复app-vue下modal标题不居中
22
+
23
+ fix: #459 TS setConfig 声明异常
24
+
25
+ feat: tabs组件增加longPress长按事件
26
+
27
+ feat: 新增showRight属性控制collapse右侧图标显隐
28
+
29
+ fix: 优化nvue下css警告
30
+
1
31
  ## 3.3.7(2024-07-29)
2
32
  feat: 支持IndexList组件支持在弹窗等场景下使用及联动优化
3
33
 
@@ -66,6 +66,16 @@ export const props = defineMixin({
66
66
  radius: {
67
67
  type: [String, Number],
68
68
  default: () => defProps.image.radius
69
+ },
70
+ // 自适应换行
71
+ autoWrap: {
72
+ type: Boolean,
73
+ default: () => defProps.album.autoWrap
74
+ },
75
+ // 单位
76
+ unit: {
77
+ type: [String],
78
+ default: () => defProps.album.unit
69
79
  }
70
80
  }
71
81
  })
@@ -6,6 +6,7 @@
6
6
  v-for="(arr, index) in showUrls"
7
7
  :forComputedUse="albumWidth"
8
8
  :key="index"
9
+ :style="{flexWrap: autoWrap ? 'wrap' : 'nowrap'}"
9
10
  >
10
11
  <view
11
12
  class="u-album__row__wrapper"
@@ -85,6 +86,8 @@ const dom = uni.requireNativePlugin('dom')
85
86
  * @property {Boolean} showMore 超出maxCount时是否显示查看更多的提示 (默认 true )
86
87
  * @property {String} shape 图片形状,circle-圆形,square-方形 (默认 'square' )
87
88
  * @property {String | Number} radius 圆角值,单位任意,如果为数值,则为px单位 (默认 0 )
89
+ * @property {Boolean} autoWrap 自适应换行模式,不受rowCount限制,图片会自动换行 (默认 false )
90
+ * @property {String} unit 图片单位 (默认 px )
88
91
  * @event {Function} albumWidth 某些特殊的情况下,需要让文字与相册的宽度相等,这里事件的形式对外发送 (回调参数 width )
89
92
  * @example <u-album :urls="urls2" @albumWidth="width => albumWidth = width" multipleSize="68" ></u-album>
90
93
  */
@@ -124,42 +127,48 @@ export default {
124
127
  marginBottom: addUnit(space)
125
128
  }
126
129
  // 如果为最后一行,则每个图片都无需下边框
127
- if (index1 === rowLen) style.marginBottom = 0
130
+ if (index1 === rowLen && !this.autoWrap) style.marginBottom = 0
128
131
  // 每行的最右边一张和总长度的最后一张无需右边框
129
- if (
130
- index2 === rowCount ||
131
- (index1 === rowLen &&
132
- index2 === this.showUrls[index1 - 1].length)
133
- )
134
- style.marginRight = 0
132
+ if (!this.autoWrap) {
133
+ if (
134
+ index2 === rowCount ||
135
+ (index1 === rowLen &&
136
+ index2 === this.showUrls[index1 - 1].length)
137
+ )
138
+ style.marginRight = 0
139
+ }
135
140
  return style
136
141
  }
137
142
  },
138
143
  // 将数组划分为二维数组
139
144
  showUrls() {
140
- const arr = []
141
- this.urls.map((item, index) => {
142
- // 限制最大展示数量
143
- if (index + 1 <= this.maxCount) {
144
- // 计算该元素为第几个素组内
145
- const itemIndex = Math.floor(index / this.rowCount)
146
- // 判断对应的索引是否存在
147
- if (!arr[itemIndex]) {
148
- arr[itemIndex] = []
145
+ if (this.autoWrap) {
146
+ return [ this.urls.slice(0, this.maxCount) ];
147
+ } else {
148
+ const arr = []
149
+ this.urls.map((item, index) => {
150
+ // 限制最大展示数量
151
+ if (index + 1 <= this.maxCount) {
152
+ // 计算该元素为第几个素组内
153
+ const itemIndex = Math.floor(index / this.rowCount)
154
+ // 判断对应的索引是否存在
155
+ if (!arr[itemIndex]) {
156
+ arr[itemIndex] = []
157
+ }
158
+ arr[itemIndex].push(item)
149
159
  }
150
- arr[itemIndex].push(item)
151
- }
152
- })
153
- return arr
160
+ })
161
+ return arr
162
+ }
154
163
  },
155
164
  imageWidth() {
156
165
  return addUnit(
157
- this.urls.length === 1 ? this.singleWidth : this.multipleSize
166
+ this.urls.length === 1 ? this.singleWidth : this.multipleSize, this.unit
158
167
  )
159
168
  },
160
169
  imageHeight() {
161
170
  return addUnit(
162
- this.urls.length === 1 ? this.singleHeight : this.multipleSize
171
+ this.urls.length === 1 ? this.singleHeight : this.multipleSize, this.unit
163
172
  )
164
173
  },
165
174
  // 此变量无实际用途,仅仅是为了利用computed特性,让其在urls长度等变化时,重新计算图片的宽度
@@ -248,7 +257,6 @@ export default {
248
257
 
249
258
  &__row {
250
259
  @include flex(row);
251
- flex-wrap: wrap;
252
260
 
253
261
  &__wrapper {
254
262
  position: relative;
@@ -469,6 +469,7 @@
469
469
 
470
470
  &__title {
471
471
  display: flex;
472
+ flex-direction: column;
472
473
  font-size: 14px;
473
474
  line-height: 42px;
474
475
  height: 42px;
@@ -91,7 +91,7 @@
91
91
  }
92
92
  },
93
93
  computed: {
94
- // 是否禁用,如果父组件u-raios-group禁用的话,将会忽略子组件的配置
94
+ // 是否禁用,如果父组件u-radios-group禁用的话,将会忽略子组件的配置
95
95
  elDisabled() {
96
96
  return this.disabled !== '' ? this.disabled : this.parentData.disabled !== null ? this.parentData.disabled : false;
97
97
  },
@@ -56,6 +56,11 @@ export const props = defineMixin({
56
56
  duration: {
57
57
  type: Number,
58
58
  default: () => defProps.collapseItem.duration
59
- }
59
+ },
60
+ // 显示右侧图标
61
+ showRight: {
62
+ type: Boolean,
63
+ default: () => defProps.collapseItem.showRight
64
+ },
60
65
  }
61
66
  })
@@ -33,9 +33,11 @@
33
33
  </slot>
34
34
  </template>
35
35
  <template #right-icon>
36
- <u-icon v-if="!$slots['right-icon']" :size="16" name="arrow-right"></u-icon>
37
- <slot name="right-icon">
38
- </slot>
36
+ <template v-if="showRight">
37
+ <u-icon v-if="!$slots['right-icon']" :size="16" name="arrow-right"></u-icon>
38
+ <slot name="right-icon">
39
+ </slot>
40
+ </template>
39
41
  </template>
40
42
  </u-cell>
41
43
  <view
@@ -244,7 +244,7 @@
244
244
  &__popup {
245
245
  position: relative;
246
246
  z-index: 10;
247
- transition: all 0.3s;
247
+ transition: transform 0.3s;
248
248
  transform: translate3D(0, -100%, 0);
249
249
  overflow: hidden;
250
250
  }
@@ -441,7 +441,14 @@
441
441
  // #endif
442
442
 
443
443
  // #ifdef APP-NVUE
444
- dom.getComponentRect(this.$refs.header, res => {
444
+ let headerRef = this.$refs.header
445
+ if (!headerRef) {
446
+ resolve({
447
+ width: 0,
448
+ height: 0
449
+ })
450
+ }
451
+ dom.getComponentRect(headerRef, res => {
445
452
  resolve(res.size)
446
453
  })
447
454
  // #endif
@@ -521,7 +528,6 @@
521
528
 
522
529
  &__letter {
523
530
  position: absolute;
524
- margin: auto;
525
531
  right: 0;
526
532
  text-align: center;
527
533
  z-index: 3;
@@ -97,7 +97,7 @@
97
97
  // 图片高度,单位rpx
98
98
  height: {
99
99
  type: [Number, String],
100
- default: '450'
100
+ default: '200'
101
101
  }
102
102
  },
103
103
  data() {
@@ -207,9 +207,12 @@
207
207
  });
208
208
  })
209
209
  // mounted的时候,不一定挂载了这个元素,延时30ms,否则会报错或者不报错,但是也没有效果
210
+
210
211
  setTimeout(() => {
212
+ // #ifndef APP-NVUE
211
213
  // 这里是组件内获取布局状态,不能用uni.createIntersectionObserver,而必须用this.createIntersectionObserver
212
214
  // this.disconnectObserver('contentObserver');
215
+ // nvue 里不支持
213
216
  const contentObserver = uni.createIntersectionObserver(this);
214
217
  // 要理解这里怎么计算的,请看这个:
215
218
  // https://blog.csdn.net/qq_25324335/article/details/83687695
@@ -225,6 +228,10 @@
225
228
  }
226
229
  })
227
230
  this.contentObserver = contentObserver;
231
+ // #endif
232
+ // #ifdef APP-NVUE
233
+ this.isShow = true;
234
+ // #endif
228
235
  }, 30)
229
236
  }
230
237
  }
@@ -239,13 +246,13 @@
239
246
  }
240
247
 
241
248
  .u-lazy-item {
242
- width: 100%;
243
249
  // 骗系统开启硬件加速
244
250
  transform: transition3d(0, 0, 0);
251
+ /* #ifndef APP-NVUE */
245
252
  // 防止图片加载“闪一下”
246
253
  will-change: transform;
247
- /* #ifndef APP-NVUE */
248
254
  display: block;
255
+ width: 100%;
249
256
  /* #endif */
250
257
  }
251
258
  </style>
@@ -315,7 +315,9 @@
315
315
  height: $u-loading-icon-dot-height;
316
316
 
317
317
  &:before {
318
+ /* #ifndef APP-NVUE */
318
319
  display: block;
320
+ /* #endif */
319
321
  width: $u-loading-icon-dot-before-width;
320
322
  height: $u-loading-icon-dot-before-height;
321
323
  margin: $u-loading-icon-dot-before-margin;
@@ -47,6 +47,11 @@ export const props = defineMixin({
47
47
  loadingColor: {
48
48
  type: String,
49
49
  default: () => defProps.loadingPage.loadingColor
50
- }
50
+ },
51
+ // 层级
52
+ zIndex: {
53
+ type: [Number],
54
+ default: () => defProps.loadingPage.zIndex
55
+ },
51
56
  }
52
57
  })
@@ -9,6 +9,8 @@
9
9
  bottom: 0,
10
10
  backgroundColor: bgColor,
11
11
  display: 'flex',
12
+ zIndex: zIndex,
13
+ ...customStyle
12
14
  }"
13
15
  >
14
16
  <view class="u-loading-page">
@@ -64,6 +66,7 @@ import { addUnit } from '../../libs/function/index';
64
66
  * @property {String | Number} fontSize 文字大小 (默认 19 )
65
67
  * @property {String | Number} iconSize 图标大小 (默认 28 )
66
68
  * @property {String} loadingColor 加载中图标的颜色,只能rgb或者十六进制颜色值 (默认 '#C8C8C8' )
69
+ * @property {Number} zIndex z-index层级 (默认10 )
67
70
  * @property {Object} customStyle 自定义样式
68
71
  * @example <u-loading mode="circle"></u-loading>
69
72
  */
@@ -81,6 +81,11 @@ export const props = defineMixin({
81
81
  confirmButtonShape: {
82
82
  type: String,
83
83
  default: () => defProps.modal.confirmButtonShape
84
- }
84
+ },
85
+ // 文案对齐方式
86
+ contentTextAlign: {
87
+ type: String,
88
+ default: () => defProps.modal.contentTextAlign
89
+ },
85
90
  }
86
91
  })
@@ -31,7 +31,9 @@
31
31
  }"
32
32
  >
33
33
  <slot>
34
- <text class="u-modal__content__text">{{ content }}</text>
34
+ <text class="u-modal__content__text" :style="{textAlign: contentTextAlign}">
35
+ {{ content }}
36
+ </text>
35
37
  </slot>
36
38
  </view>
37
39
  <view
@@ -175,6 +177,9 @@
175
177
 
176
178
  &__title {
177
179
  display: flex;
180
+ flex-direction: column;
181
+ justify-content: center;
182
+ align-items: center;
178
183
  font-size: 16px;
179
184
  font-weight: bold;
180
185
  color: $u-content-color;
@@ -407,7 +407,9 @@ export default {
407
407
  ._a {
408
408
  padding: 1.5px 0 1.5px 0;
409
409
  color: #366092;
410
+ /* #ifndef APP-NVUE */
410
411
  word-break: break-all;
412
+ /* #endif */
411
413
  }
412
414
 
413
415
  /* a 标签点击态效果 */
@@ -425,7 +427,9 @@ export default {
425
427
  /* 内部样式 */
426
428
 
427
429
  ._block {
430
+ /* #ifndef APP-NVUE */
428
431
  display: block;
432
+ /* #endif */
429
433
  }
430
434
 
431
435
  ._b,
@@ -472,7 +476,9 @@ export default {
472
476
  ._h4,
473
477
  ._h5,
474
478
  ._h6 {
479
+ /* #ifndef APP-NVUE */
475
480
  display: block;
481
+ /* #endif */
476
482
  font-weight: bold;
477
483
  }
478
484
 
@@ -494,7 +500,9 @@ export default {
494
500
 
495
501
  ._ol,
496
502
  ._ul {
503
+ /* #ifndef APP-NVUE */
497
504
  display: block;
505
+ /* #endif */
498
506
  padding-left: 40px;
499
507
  margin: 1em 0;
500
508
  }
@@ -4,7 +4,9 @@
4
4
  :style="[addStyle(customStyle)]"
5
5
  >
6
6
  <template v-if="!useNative || isRange">
7
- <view ref="u-slider-inner" class="u-slider-inner" @tap="onClick"
7
+ <view ref="u-slider-inner" class="u-slider-inner" @click="onClick"
8
+ @onTouchStart="onTouchStart2($event, 1)" @touchmove="onTouchMove2($event, 1)"
9
+ @touchend="onTouchEnd2($event, 1)" @touchcancel="onTouchEnd2($event, 1)"
8
10
  :class="[disabled ? 'u-slider--disabled' : '']" :style="{
9
11
  height: (isRange && showValue) ? (getPx(blockSize) + 24) + 'px' : (getPx(blockSize)) + 'px',
10
12
  }"
@@ -248,6 +250,22 @@
248
250
  }
249
251
  // 标示当前的状态为开始触摸滑动
250
252
  this.status = 'start';
253
+
254
+ let clientX = 0;
255
+ // #ifndef APP-NVUE
256
+ clientX = touches.clientX;
257
+ // #endif
258
+ // #ifdef APP-NVUE
259
+ clientX = touches.screenX;
260
+ // #endif
261
+ this.distanceX = clientX - this.sliderRect.left;
262
+ // 获得移动距离对整个滑块的值,此为带有多位小数的值,不能用此更新视图
263
+ // 否则造成通信阻塞,需要每改变一个step值时修改一次视图
264
+ this.newValue = ((this.distanceX / this.sliderRect.width) * (this.max - this.min)) + parseFloat(this.min);
265
+ this.status = 'moving';
266
+ // 发出moving事件
267
+ this.$emit('changing');
268
+ this.updateValue(this.newValue, true, index);
251
269
  },
252
270
  onTouchMove(event, index = 1) {
253
271
  if (this.disabled) return;
@@ -255,7 +273,7 @@
255
273
  // 触摸后第一次移动已经将status设置为moving状态,故触摸第二次移动不会触发本事件
256
274
  if (this.status == 'start') this.$emit('start');
257
275
  let touches = event.touches[0];
258
- // console.log('touchs', touches)
276
+ console.log('touchs', touches)
259
277
  // 滑块的左边不一定跟屏幕左边接壤,所以需要减去最外层父元素的左边值
260
278
  let clientX = 0;
261
279
  // #ifndef APP-NVUE
@@ -281,6 +299,32 @@
281
299
  }
282
300
  this.status = 'end';
283
301
  },
302
+ onTouchStart2(event, index = 1) {
303
+ if (!this.isRange) {
304
+ this.onChangeStart(event, index);
305
+ }
306
+ },
307
+ onTouchMove2(event, index = 1) {
308
+ if (!this.isRange) {
309
+ this.onTouchMove(event, index);
310
+ }
311
+ },
312
+ onTouchEnd2(event, index = 1) {
313
+ if (!this.isRange) {
314
+ this.onTouchEnd(event, index);
315
+ }
316
+ },
317
+ onClick(event) {
318
+ if (this.disabled) return;
319
+ // 直接点击滑块的情况,计算方式与onTouchMove方法相同
320
+ // console.log('click', event)
321
+ // #ifndef APP-NVUE
322
+ // nvue下暂时无法获取坐标
323
+ let clientX = event.detail.x - this.sliderRect.left
324
+ this.newValue = ((clientX / this.sliderRect.width) * (this.max - this.min)) + parseFloat(this.min);
325
+ this.updateValue(this.newValue, false, 1);
326
+ // #endif
327
+ },
284
328
  updateValue(value, drag, index = 1) {
285
329
  // 去掉小数部分,同时也是对step步进的处理
286
330
  let valueFormat = this.format(value, index);
@@ -350,12 +394,6 @@
350
394
  / this.step
351
395
  ) * this.step;
352
396
  }
353
- },
354
- onClick(event) {
355
- if (this.disabled) return;
356
- // 直接点击滑块的情况,计算方式与onTouchMove方法相同
357
- const value = ((event.detail.x - this.sliderRect.left) / this.sliderRect.width) * 100;
358
- this.updateValue(value, false);
359
397
  }
360
398
  }
361
399
  }
@@ -126,8 +126,10 @@
126
126
  align-items: center;
127
127
  justify-content: center;
128
128
  flex: 1;
129
+ /* #ifndef APP-NVUE */
129
130
  width: 100%;
130
131
  height: 100%;
132
+ /* #endif */
131
133
  /* #ifdef H5 */
132
134
  cursor: pointer;
133
135
  /* #endif */
@@ -20,6 +20,7 @@
20
20
  v-for="(item, index) in list"
21
21
  :key="index"
22
22
  @tap="clickHandler(item, index)"
23
+ @longpress="longPressHandler(item,index)"
23
24
  :ref="`u-tabs__wrapper__nav__item-${index}`"
24
25
  :style="[addStyle(itemStyle), {flex: scrollable ? '' : 1}]"
25
26
  :class="[`u-tabs__wrapper__nav__item-${index}`, item.disabled && 'u-tabs__wrapper__nav__item--disabled']"
@@ -102,7 +103,8 @@
102
103
  * @property {String} keyName 从`list`元素对象中读取的键名(默认 'name' )
103
104
  * @event {Function(index)} change 标签改变时触发 index: 点击了第几个tab,索引从0开始
104
105
  * @event {Function(index)} click 点击标签时触发 index: 点击了第几个tab,索引从0开始
105
- * @example <u-tabs :list="list" :is-scroll="false" :current="current" @change="change"></u-tabs>
106
+ * @event {Function(index)} longPress 长按标签时触发 index: 点击了第几个tab,索引从0开始
107
+ * @example <u-tabs :list="list" :is-scroll="false" :current="current" @change="change" @longPress="longPress"></u-tabs>
106
108
  */
107
109
  export default {
108
110
  name: 'u-tabs',
@@ -160,7 +162,7 @@
160
162
  async mounted() {
161
163
  this.init()
162
164
  },
163
- emits: ['click', 'change', 'update:current'],
165
+ emits: ['click', 'longPress', 'change', 'update:current'],
164
166
  methods: {
165
167
  addStyle,
166
168
  addUnit,
@@ -218,6 +220,13 @@
218
220
  index
219
221
  }, index)
220
222
  },
223
+ // 长按事件
224
+ longPressHandler(item, index) {
225
+ this.$emit('longPress', {
226
+ ...item,
227
+ index
228
+ })
229
+ },
221
230
  init() {
222
231
  sleep().then(() => {
223
232
  this.resize()
@@ -1,9 +1,9 @@
1
1
  <template>
2
2
  <view class="u-waterfall">
3
- <view id="u-left-column" class="u-column">
3
+ <view ref="u-left-column" id="u-left-column" class="u-column">
4
4
  <slot name="left" :leftList="leftList"></slot>
5
5
  </view>
6
- <view id="u-right-column" class="u-column">
6
+ <view ref="u-right-column" id="u-right-column" class="u-column">
7
7
  <slot name="right" :rightList="rightList"></slot>
8
8
  </view>
9
9
  </view>
@@ -18,6 +18,8 @@
18
18
  * @property {String Number} add-time 单条数据添加到队列的时间间隔,单位ms,见上方注意事项说明(默认200)
19
19
  * @example <u-waterfall :flowList="flowList"></u-waterfall>
20
20
  */
21
+ import { mpMixin } from '../../libs/mixin/mpMixin';
22
+ import { mixin } from '../../libs/mixin/mixin';
21
23
  export default {
22
24
  name: "u-waterfall",
23
25
  props: {
@@ -54,6 +56,7 @@
54
56
  default: 'id'
55
57
  }
56
58
  },
59
+ mixins: [mpMixin, mixin],
57
60
  data() {
58
61
  return {
59
62
  leftList: [],
@@ -156,7 +159,7 @@
156
159
  // #endif
157
160
  // #ifdef VUE3
158
161
  index = this.modelValue.findIndex(val => val[this.idKey] == id);
159
- if (index != -1) this.$emit('input', this.modelValue.splice(index, 1));
162
+ if (index != -1) this.$emit('update:modelValue', this.modelValue.splice(index, 1));
160
163
  // #endif
161
164
  },
162
165
  // 修改某条数据的某个属性
@@ -216,10 +219,13 @@
216
219
  @include flex;
217
220
  flex: 1;
218
221
  flex-direction: column;
222
+ overflow: hidden;
223
+ /* #ifndef APP-NVUE */
219
224
  height: 100%;
225
+ /* #endif */
220
226
  }
221
227
 
222
228
  .u-image {
223
- width: 100%;
229
+ max-width: 100%;
224
230
  }
225
231
  </style>
@@ -20,6 +20,8 @@ export default {
20
20
  maxCount: 9,
21
21
  previewFullImage: true,
22
22
  rowCount: 3,
23
- showMore: true
23
+ showMore: true,
24
+ autoWrap: false,
25
+ unit: 'px'
24
26
  }
25
27
  }
@@ -20,6 +20,7 @@ export default {
20
20
  align: 'left',
21
21
  name: '',
22
22
  icon: '',
23
- duration: 300
23
+ duration: 300,
24
+ showRight: true
24
25
  }
25
26
  }
@@ -18,6 +18,7 @@ export default {
18
18
  color: '#C8C8C8',
19
19
  fontSize: 19,
20
20
  iconSize: 28,
21
- loadingColor: '#C8C8C8'
21
+ loadingColor: '#C8C8C8',
22
+ zIndex: 10
22
23
  }
23
24
  }
@@ -25,6 +25,7 @@ export default {
25
25
  closeOnClickOverlay: false,
26
26
  negativeTop: 0,
27
27
  width: '650rpx',
28
- confirmButtonShape: ''
28
+ confirmButtonShape: '',
29
+ contentTextAlign: 'left'
29
30
  }
30
31
  }
@@ -216,6 +216,7 @@
216
216
  // 多轴交叉时的对齐方式
217
217
 
218
218
  // 起点对齐
219
+ /* #ifndef APP-NVUE */
219
220
  .u-flex-content-start {
220
221
  align-content: flex-start;
221
222
  }
@@ -258,6 +259,8 @@
258
259
  flex-shrink: 1;
259
260
  }
260
261
 
262
+ /* #endif */
263
+
261
264
  // 定义内外边距,历遍1-80
262
265
  @for $i from 0 through 80 {
263
266
  // 只要双数和能被5除尽的数
@@ -1,7 +1,11 @@
1
1
  import { defineMixin } from '../vue'
2
- import { deepMerge, $parent } from '../function/index'
2
+ import { deepMerge, $parent, sleep } from '../function/index'
3
3
  import test from '../function/test'
4
4
  import route from '../util/route'
5
+ // #ifdef APP-NVUE
6
+ // 由于weex为阿里的KPI业绩考核的产物,所以不支持百分比单位,这里需要通过dom查询组件的宽度
7
+ const dom = uni.requireNativePlugin('dom')
8
+ // #endif
5
9
 
6
10
  export const mixin = defineMixin({
7
11
  // 定义每个组件都可能需要用到的外部样式以及类名
@@ -107,6 +111,7 @@ export const mixin = defineMixin({
107
111
  // 解决办法为在组件根部再套一个没有任何作用的view元素
108
112
  $uGetRect(selector, all) {
109
113
  return new Promise((resolve) => {
114
+ // #ifndef APP-NVUE
110
115
  uni.createSelectorQuery()
111
116
  .in(this)[all ? 'selectAll' : 'select'](selector)
112
117
  .boundingClientRect((rect) => {
@@ -118,6 +123,29 @@ export const mixin = defineMixin({
118
123
  }
119
124
  })
120
125
  .exec()
126
+ // #endif
127
+
128
+ // #ifdef APP-NVUE
129
+ sleep(30).then(() => {
130
+ let selectorNvue = selector.substring(1) // 去掉开头的#或者.
131
+ let selectorRef = this.$refs[selectorNvue]
132
+ if (!selectorRef) {
133
+ // console.log('不存在元素,请检查是否设置了ref属性' + selectorNvue + '。')
134
+ resolve({
135
+ with: 0,
136
+ height: 0,
137
+ left: 0,
138
+ right: 0,
139
+ top: 0,
140
+ bottom: 0
141
+ })
142
+ }
143
+ dom.getComponentRect(selectorRef, res => {
144
+ // console.log(res)
145
+ resolve(res.size)
146
+ })
147
+ })
148
+ // #endif
121
149
  })
122
150
  },
123
151
  getParentData(parentName = '') {
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.7",
5
+ "version": "3.3.9",
6
6
  "description": "uview-plus已兼容vue3,全面的组件和便捷的工具会让您信手拈来,如鱼得水",
7
7
  "keywords": [
8
8
  "uview",
package/types/index.d.ts CHANGED
@@ -77,9 +77,8 @@ declare module 'uview-plus' {
77
77
  interface Config {
78
78
  v: string;
79
79
  version: string;
80
- type: ['primary', 'success', 'info', 'error', 'warning'];
81
- color: Record<'u-primary' | 'u-warning' | 'u-success' | 'u-error' | 'u-info' | 'u-main-color' | 'u-content-color' | 'u-tips-color' | 'u-light-color', string>;
82
- unit: 'px'
80
+ color: Partial<Color>;
81
+ unit: 'px' | 'rpx'
83
82
  }
84
83
  interface Color {
85
84
  primary: string,
@@ -95,7 +94,7 @@ declare module 'uview-plus' {
95
94
  borderColor: string
96
95
  }
97
96
  interface GlobalConfig {
98
- config: Config;
97
+ config: Partial<Config>;
99
98
  props: {};
100
99
  }
101
100
  interface $u {
@@ -149,7 +148,7 @@ declare module 'uview-plus' {
149
148
  platform: string;
150
149
  }
151
150
 
152
- export function setConfig(config: GlobalConfig): void;
151
+ export function setConfig(config: Partial<GlobalConfig>): void;
153
152
 
154
153
  global {
155
154
  interface Uni {