uview-plus 3.2.7 → 3.2.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.
Files changed (120) hide show
  1. package/changelog.md +7 -0
  2. package/components/u--form/u--form.vue +7 -7
  3. package/components/u--image/u--image.vue +3 -3
  4. package/components/u--input/u--input.vue +9 -9
  5. package/components/u--textarea/u--textarea.vue +3 -3
  6. package/components/u-action-sheet/u-action-sheet.vue +5 -4
  7. package/components/u-album/u-album.vue +9 -7
  8. package/components/u-alert/u-alert.vue +9 -6
  9. package/components/u-avatar/props.js +2 -1
  10. package/components/u-avatar/u-avatar.vue +15 -11
  11. package/components/u-avatar-group/u-avatar-group.vue +9 -5
  12. package/components/u-back-top/u-back-top.vue +9 -8
  13. package/components/u-badge/u-badge.vue +10 -6
  14. package/components/u-button/u-button.vue +13 -9
  15. package/components/u-calendar/header.vue +3 -3
  16. package/components/u-calendar/month.vue +17 -15
  17. package/components/u-calendar/u-calendar.vue +10 -8
  18. package/components/u-car-keyboard/u-car-keyboard.vue +7 -6
  19. package/components/u-cell/u-cell.vue +9 -6
  20. package/components/u-cell-group/u-cell-group.vue +8 -4
  21. package/components/u-checkbox/u-checkbox.vue +13 -11
  22. package/components/u-checkbox-group/u-checkbox-group.vue +3 -3
  23. package/components/u-circle-progress/u-circle-progress.vue +5 -4
  24. package/components/u-code/u-code.vue +3 -3
  25. package/components/u-code-input/u-code-input.vue +9 -8
  26. package/components/u-col/u-col.vue +9 -8
  27. package/components/u-collapse/u-collapse.vue +3 -3
  28. package/components/u-collapse-item/u-collapse-item.vue +32 -15
  29. package/components/u-column-notice/u-column-notice.vue +8 -6
  30. package/components/u-count-down/u-count-down.vue +3 -3
  31. package/components/u-count-to/u-count-to.vue +6 -4
  32. package/components/u-datetime-picker/u-datetime-picker.vue +15 -15
  33. package/components/u-divider/u-divider.vue +7 -5
  34. package/components/u-dropdown/u-dropdown.vue +12 -10
  35. package/components/u-dropdown-item/u-dropdown-item.vue +7 -5
  36. package/components/u-empty/u-empty.vue +12 -8
  37. package/components/u-form/u-form.vue +12 -10
  38. package/components/u-form-item/u-form-item.vue +17 -11
  39. package/components/u-gap/u-gap.vue +3 -3
  40. package/components/u-grid/u-grid.vue +18 -7
  41. package/components/u-grid-item/u-grid-item.vue +14 -9
  42. package/components/u-icon/u-icon.vue +21 -19
  43. package/components/u-image/u-image.vue +18 -16
  44. package/components/u-index-anchor/u-index-anchor.vue +11 -9
  45. package/components/u-index-item/u-index-item.vue +6 -5
  46. package/components/u-index-list/u-index-list.vue +20 -18
  47. package/components/u-input/u-input.vue +12 -11
  48. package/components/u-keyboard/u-keyboard.vue +3 -3
  49. package/components/u-line/u-line.vue +7 -6
  50. package/components/u-line-progress/u-line-progress.vue +11 -8
  51. package/components/u-link/u-link.vue +9 -8
  52. package/components/u-list/u-list.vue +9 -9
  53. package/components/u-list-item/u-list-item.vue +5 -4
  54. package/components/u-loading-icon/u-loading-icon.vue +14 -10
  55. package/components/u-loading-page/u-loading-page.vue +10 -7
  56. package/components/u-loadmore/u-loadmore.vue +12 -10
  57. package/components/u-modal/u-modal.vue +7 -5
  58. package/components/u-navbar/u-navbar.vue +12 -7
  59. package/components/u-no-network/u-no-network.vue +6 -6
  60. package/components/u-notice-bar/u-notice-bar.vue +6 -5
  61. package/components/u-notify/u-notify.vue +19 -15
  62. package/components/u-number-box/u-number-box.vue +8 -7
  63. package/components/u-number-keyboard/u-number-keyboard.vue +7 -7
  64. package/components/u-overlay/u-overlay.vue +5 -5
  65. package/components/u-picker/u-picker.vue +19 -15
  66. package/components/u-picker-column/u-picker-column.vue +3 -3
  67. package/components/u-popup/u-popup.vue +13 -13
  68. package/components/u-radio/u-radio.vue +12 -12
  69. package/components/u-radio-group/u-radio-group.vue +3 -3
  70. package/components/u-rate/u-rate.vue +16 -14
  71. package/components/u-read-more/u-read-more.vue +9 -7
  72. package/components/u-row/u-row.vue +8 -7
  73. package/components/u-row-notice/u-row-notice.vue +14 -12
  74. package/components/u-safe-bottom/u-safe-bottom.vue +5 -4
  75. package/components/u-scroll-list/nvue.js +4 -4
  76. package/components/u-scroll-list/u-scroll-list.vue +13 -10
  77. package/components/u-search/u-search.vue +8 -6
  78. package/components/u-skeleton/u-skeleton.vue +20 -17
  79. package/components/u-slider/mpwxs.js +3 -2
  80. package/components/u-slider/nvue - /345/211/257/346/234/254.js" +2 -2
  81. package/components/u-slider/nvue.js +2 -2
  82. package/components/u-slider/u-slider.vue +8 -5
  83. package/components/u-status-bar/u-status-bar.vue +6 -5
  84. package/components/u-steps/u-steps.vue +5 -4
  85. package/components/u-steps-item/u-steps-item.vue +9 -7
  86. package/components/u-sticky/u-sticky.vue +12 -10
  87. package/components/u-subsection/u-subsection.vue +8 -6
  88. package/components/u-swipe-action/u-swipe-action.vue +3 -3
  89. package/components/u-swipe-action-item/nvue - backup.js +3 -3
  90. package/components/u-swipe-action-item/nvue.js +3 -3
  91. package/components/u-swipe-action-item/u-swipe-action-item.vue +8 -5
  92. package/components/u-swiper/u-swiper.vue +35 -24
  93. package/components/u-swiper-indicator/u-swiper-indicator.vue +10 -7
  94. package/components/u-switch/u-switch.vue +15 -13
  95. package/components/u-tabbar/u-tabbar.vue +6 -5
  96. package/components/u-tabbar-item/u-tabbar-item.vue +7 -5
  97. package/components/u-table/u-table.vue +3 -3
  98. package/components/u-tabs/u-tabs.vue +18 -14
  99. package/components/u-tabs-item/u-tabs-item.vue +3 -3
  100. package/components/u-tag/props.js +2 -2
  101. package/components/u-tag/u-tag.vue +6 -4
  102. package/components/u-td/u-td.vue +3 -3
  103. package/components/u-text/u-text.vue +12 -10
  104. package/components/u-text/value.js +14 -12
  105. package/components/u-textarea/u-textarea.vue +11 -8
  106. package/components/u-toast/u-toast.vue +12 -9
  107. package/components/u-toolbar/u-toolbar.vue +3 -3
  108. package/components/u-tooltip/u-tooltip.vue +18 -17
  109. package/components/u-tr/u-tr.vue +3 -3
  110. package/components/u-transition/transition.js +2 -2
  111. package/components/u-transition/u-transition.vue +6 -5
  112. package/components/u-upload/mixin.js +4 -3
  113. package/components/u-upload/u-upload.vue +20 -17
  114. package/index.js +0 -5
  115. package/libs/function/index.js +27 -20
  116. package/libs/function/throttle.js +2 -2
  117. package/libs/mixin/mixin.js +14 -6
  118. package/libs/mixin/style.js +23 -4
  119. package/libs/util/route.js +6 -6
  120. package/package.json +1 -1
@@ -19,19 +19,19 @@
19
19
  :lazy-load="lazyLoad"
20
20
  class="u-image__image"
21
21
  :style="{
22
- borderRadius: shape == 'circle' ? '10000px' : $u.addUnit(radius),
23
- width: $u.addUnit(width),
24
- height: $u.addUnit(height)
22
+ borderRadius: shape == 'circle' ? '10000px' : addUnit(radius),
23
+ width: addUnit(width),
24
+ height: addUnit(height)
25
25
  }"
26
26
  ></image>
27
27
  <view
28
28
  v-if="showLoading && loading"
29
29
  class="u-image__loading"
30
30
  :style="{
31
- borderRadius: shape == 'circle' ? '50%' : $u.addUnit(radius),
31
+ borderRadius: shape == 'circle' ? '50%' : addUnit(radius),
32
32
  backgroundColor: this.bgColor,
33
- width: $u.addUnit(width),
34
- height: $u.addUnit(height)
33
+ width: addUnit(width),
34
+ height: addUnit(height)
35
35
  }"
36
36
  >
37
37
  <slot name="loading">
@@ -46,9 +46,9 @@
46
46
  v-if="showError && isError && !loading"
47
47
  class="u-image__error"
48
48
  :style="{
49
- borderRadius: shape == 'circle' ? '50%' : $u.addUnit(radius),
50
- width: $u.addUnit(width),
51
- height: $u.addUnit(height)
49
+ borderRadius: shape == 'circle' ? '50%' : addUnit(radius),
50
+ width: addUnit(width),
51
+ height: addUnit(height)
52
52
  }"
53
53
  >
54
54
  <slot name="error">
@@ -64,9 +64,10 @@
64
64
  </template>
65
65
 
66
66
  <script>
67
- import props from './props.js';
68
- import mpMixin from '../../libs/mixin/mpMixin.js';
69
- import mixin from '../../libs/mixin/mixin.js';
67
+ import props from './props';
68
+ import mpMixin from '../../libs/mixin/mpMixin';
69
+ import mixin from '../../libs/mixin/mixin';
70
+ import { addUnit, addStyle, deepMerge } from '../../libs/function/index';
70
71
  /**
71
72
  * Image 图片
72
73
  * @description 此组件为uni-app的image组件的加强版,在继承了原有功能外,还支持淡入动画、加载中、加载失败提示、圆角值和形状等。
@@ -131,10 +132,10 @@
131
132
  wrapStyle() {
132
133
  let style = {};
133
134
  // 通过调用addUnit()方法,如果有单位,如百分比,px单位等,直接返回,如果是纯粹的数值,则加上rpx单位
134
- style.width = this.$u.addUnit(this.width);
135
- style.height = this.$u.addUnit(this.height);
135
+ style.width = addUnit(this.width);
136
+ style.height = addUnit(this.height);
136
137
  // 如果是显示圆形,设置一个很多的半径值即可
137
- style.borderRadius = this.shape == 'circle' ? '10000px' : uni.$u.addUnit(this.radius)
138
+ style.borderRadius = this.shape == 'circle' ? '10000px' : addUnit(this.radius)
138
139
  // 如果设置圆角,必须要有hidden,否则可能圆角无效
139
140
  style.overflow = this.radius > 0 ? 'hidden' : 'visible'
140
141
  // if (this.fade) {
@@ -144,7 +145,7 @@
144
145
  // style.transitionTimingFunction = 'ease-in-out'
145
146
  // style.transitionProperty = 'opacity'
146
147
  // }
147
- return uni.$u.deepMerge(style, uni.$u.addStyle(this.customStyle));
148
+ return deepMerge(style, addStyle(this.customStyle));
148
149
 
149
150
  }
150
151
  },
@@ -153,6 +154,7 @@
153
154
  },
154
155
  emits: ['click', 'error', 'load'],
155
156
  methods: {
157
+ addUnit,
156
158
  // 点击图片
157
159
  onClick() {
158
160
  this.$emit('click')
@@ -6,14 +6,14 @@
6
6
  class="u-index-anchor u-border-bottom"
7
7
  :ref="`u-index-anchor-${text}`"
8
8
  :style="{
9
- height: $u.addUnit(height),
9
+ height: addUnit(height),
10
10
  backgroundColor: bgColor
11
11
  }"
12
12
  >
13
13
  <text
14
14
  class="u-index-anchor__text"
15
15
  :style="{
16
- fontSize: $u.addUnit(size),
16
+ fontSize: addUnit(size),
17
17
  color: color
18
18
  }"
19
19
  >{{ text }}</text>
@@ -24,9 +24,10 @@
24
24
  </template>
25
25
 
26
26
  <script>
27
- import props from './props.js';
28
- import mpMixin from '../../libs/mixin/mpMixin.js';
29
- import mixin from '../../libs/mixin/mixin.js';
27
+ import props from './props';
28
+ import mpMixin from '../../libs/mixin/mpMixin';
29
+ import mixin from '../../libs/mixin/mixin';
30
+ import { addUnit, $parent, error } from '../../libs/function/index';
30
31
  // #ifdef APP-NVUE
31
32
  const dom = uni.requireNativePlugin('dom')
32
33
  // #endif
@@ -52,19 +53,20 @@
52
53
  this.init()
53
54
  },
54
55
  methods: {
56
+ addUnit,
55
57
  init() {
56
58
  // 此处会活动父组件实例,并赋值给实例的parent属性
57
- const indexList = uni.$u.$parent.call(this, 'u-index-list')
59
+ const indexList = $parent.call(this, 'u-index-list')
58
60
  if (!indexList) {
59
- return uni.$u.error('u-index-anchor必须要搭配u-index-list组件使用')
61
+ return error('u-index-anchor必须要搭配u-index-list组件使用')
60
62
  }
61
63
  // 将当前实例放入到u-index-list中
62
64
  indexList.anchors.push(this)
63
- const indexListItem = uni.$u.$parent.call(this, 'u-index-item')
65
+ const indexListItem = $parent.call(this, 'u-index-item')
64
66
  // #ifndef APP-NVUE
65
67
  // 只有在非nvue下,u-index-anchor才是嵌套在u-index-item中的
66
68
  if (!indexListItem) {
67
- return uni.$u.error('u-index-anchor必须要搭配u-index-item组件使用')
69
+ return error('u-index-anchor必须要搭配u-index-item组件使用')
68
70
  }
69
71
  // 设置u-index-item的id为anchor的text标识符,因为非nvue下滚动列表需要依赖scroll-view滚动到元素的特性
70
72
  indexListItem.id = this.text.charCodeAt(0)
@@ -15,9 +15,10 @@
15
15
  </template>
16
16
 
17
17
  <script>
18
- import props from './props.js';
19
- import mpMixin from '../../libs/mixin/mpMixin.js';
20
- import mixin from '../../libs/mixin/mixin.js';
18
+ import props from './props';
19
+ import mpMixin from '../../libs/mixin/mpMixin';
20
+ import mixin from '../../libs/mixin/mixin';
21
+ import { sleep, error } from '../../libs/function/index';
21
22
  // #ifdef APP-NVUE
22
23
  // 由于weex为阿里的KPI业绩考核的产物,所以不支持百分比单位,这里需要通过dom查询组件的宽度
23
24
  const dom = uni.requireNativePlugin('dom')
@@ -53,9 +54,9 @@
53
54
  // 此处会活动父组件实例,并赋值给实例的parent属性
54
55
  this.getParentData('u-index-list')
55
56
  if (!this.parent) {
56
- return uni.$u.error('u-index-item必须要搭配u-index-list组件使用')
57
+ return error('u-index-item必须要搭配u-index-list组件使用')
57
58
  }
58
- uni.$u.sleep().then(() =>{
59
+ sleep().then(() =>{
59
60
  this.getIndexItemRect().then(size => {
60
61
  // 由于对象的引用特性,此处会同时生效到父组件的children数组的本实例的top属性中,供父组件判断读取
61
62
  this.top = Math.ceil(size.top)
@@ -6,7 +6,7 @@
6
6
  enable-back-to-top
7
7
  :offset-accuracy="1"
8
8
  :style="{
9
- maxHeight: $u.addUnit(scrollViewHeight)
9
+ maxHeight: addUnit(scrollViewHeight)
10
10
  }"
11
11
  @scroll="scrollHandler"
12
12
  ref="uList"
@@ -29,7 +29,7 @@
29
29
  :scrollIntoView="scrollIntoView"
30
30
  :offset-accuracy="1"
31
31
  :style="{
32
- maxHeight: $u.addUnit(scrollViewHeight)
32
+ maxHeight: addUnit(scrollViewHeight)
33
33
  }"
34
34
  scroll-y
35
35
  @scroll="scrollHandler"
@@ -47,7 +47,7 @@
47
47
  <view
48
48
  class="u-index-list__letter"
49
49
  ref="u-index-list__letter"
50
- :style="{ top: $u.addUnit(letterInfo.top || 100) }"
50
+ :style="{ top: addUnit(letterInfo.top || 100) }"
51
51
  @touchstart.prevent="touchStart"
52
52
  @touchmove.prevent="touchMove"
53
53
  @touchend.prevent="touchEnd"
@@ -73,7 +73,7 @@
73
73
  :customStyle="{
74
74
  position: 'fixed',
75
75
  right: '50px',
76
- top: $u.addUnit(indicatorTop),
76
+ top: addUnit(indicatorTop),
77
77
  zIndex: 2
78
78
  }"
79
79
  >
@@ -81,8 +81,8 @@
81
81
  class="u-index-list__indicator"
82
82
  :class="['u-index-list__indicator--show']"
83
83
  :style="{
84
- height: $u.addUnit(indicatorHeight),
85
- width: $u.addUnit(indicatorHeight)
84
+ height: addUnit(indicatorHeight),
85
+ width: addUnit(indicatorHeight)
86
86
  }"
87
87
  >
88
88
  <text class="u-index-list__indicator__text">{{ uIndexList[activeIndex] }}</text>
@@ -100,9 +100,10 @@
100
100
  }
101
101
  return indexList;
102
102
  }
103
- import props from './props.js';
104
- import mpMixin from '../../libs/mixin/mpMixin.js';
105
- import mixin from '../../libs/mixin/mixin.js';
103
+ import props from './props';
104
+ import mpMixin from '../../libs/mixin/mpMixin';
105
+ import mixin from '../../libs/mixin/mixin';
106
+ import { addUnit, sys, sleep, getPx } from '../../libs/function/index';
106
107
  // #ifdef APP-NVUE
107
108
  // 由于weex为阿里的KPI业绩考核的产物,所以不支持百分比单位,这里需要通过dom查询组件的宽度
108
109
  const dom = uni.requireNativePlugin('dom')
@@ -148,7 +149,7 @@
148
149
  // scroll-view的高度
149
150
  scrollViewHeight: 0,
150
151
  // 系统信息
151
- sys: uni.$u.sys(),
152
+ sys: sys(),
152
153
  scrolling: false,
153
154
  scrollIntoView: '',
154
155
  }
@@ -172,7 +173,7 @@
172
173
  uIndexList: {
173
174
  immediate: true,
174
175
  handler() {
175
- uni.$u.sleep().then(() => {
176
+ sleep().then(() => {
176
177
  this.setIndexListLetterInfo()
177
178
  })
178
179
  }
@@ -187,11 +188,12 @@
187
188
  this.setIndexListLetterInfo()
188
189
  },
189
190
  methods: {
191
+ addUnit,
190
192
  init() {
191
193
  // 设置列表的高度为整个屏幕的高度
192
194
  //减去this.customNavHeight,并将this.scrollViewHeight设置为maxHeight
193
195
  //解决当u-index-list组件放在tabbar页面时,scroll-view内容较少时,还能滚动
194
- let customNavHeight = uni.$u.getPx(this.customNavHeight)
196
+ let customNavHeight = getPx(this.customNavHeight)
195
197
  this.scrollViewHeight = this.sys.windowHeight - customNavHeight
196
198
  },
197
199
  // 索引列表被触摸
@@ -226,7 +228,7 @@
226
228
  // 触摸结束
227
229
  touchEnd(e) {
228
230
  // 延时一定时间后再隐藏指示器,为了让用户看的更直观,同时也是为了消除快速切换u-transition的show带来的影响
229
- uni.$u.sleep(300).then(() => {
231
+ sleep(300).then(() => {
230
232
  this.touching = false
231
233
  })
232
234
  },
@@ -254,7 +256,7 @@
254
256
  const {
255
257
  height
256
258
  } = size
257
- const sys = uni.$u.sys()
259
+ const sys = sys()
258
260
  const windowHeight = sys.windowHeight
259
261
  let customNavHeight = 0
260
262
  // 消除各端导航栏非原生和原生导致的差异,让索引列表字母对屏幕垂直居中
@@ -267,7 +269,7 @@
267
269
  customNavHeight = -(sys.statusBarHeight + 44)
268
270
  // #endif
269
271
  } else {
270
- customNavHeight = uni.$u.getPx(this.customNavHeight)
272
+ customNavHeight = getPx(this.customNavHeight)
271
273
  }
272
274
  this.letterInfo = {
273
275
  height,
@@ -286,7 +288,7 @@
286
288
  } = this.letterInfo
287
289
  // 对H5的pageY进行修正,这是由于uni-app自作多情在H5中将触摸点的坐标跟H5的导航栏结合导致的问题
288
290
  // #ifdef H5
289
- pageY += uni.$u.sys().windowTop
291
+ pageY += sys().windowTop
290
292
  // #endif
291
293
  // 对第一和最后一个字母做边界处理,因为用户可能在字母列表上触摸到两端的尽头后依然继续滑动
292
294
  if (pageY < top) {
@@ -311,7 +313,7 @@
311
313
  // #ifdef MP-WEIXIN
312
314
  // 微信小程序下,scroll-view的scroll-into-view属性无法对slot中的内容的id生效,只能通过设置scrollTop的形式去移动滚动条
313
315
  const customNavHeight = this.customNavHeight
314
- this.scrollTop = this.children[currentIndex].top - uni.$u.getPx(customNavHeight)
316
+ this.scrollTop = this.children[currentIndex].top - getPx(customNavHeight)
315
317
  // #endif
316
318
  // #ifdef APP-NVUE
317
319
  // 在nvue中,由于cell和header为同级元素,所以实际是需要对header(anchor)进行偏移
@@ -335,7 +337,7 @@
335
337
  if (this.touching || this.scrolling) return
336
338
  // 每过一定时间取样一次,减少资源损耗以及可能带来的卡顿
337
339
  this.scrolling = true
338
- uni.$u.sleep(10).then(() => {
340
+ sleep(10).then(() => {
339
341
  this.scrolling = false
340
342
  })
341
343
  let scrollTop = 0
@@ -77,8 +77,9 @@
77
77
 
78
78
  <script>
79
79
  import props from "./props.js";
80
- import mpMixin from '../../libs/mixin/mpMixin.js';
81
- import mixin from '../../libs/mixin/mixin.js';
80
+ import mpMixin from '../../libs/mixin/mpMixin';
81
+ import mixin from '../../libs/mixin/mixin';
82
+ import { addStyle, addUnit, deepMerge, formValidate, $parent, sleep, os } from '../../libs/function/index';
82
83
  /**
83
84
  * Input 输入框
84
85
  * @description 此组件为一个输入框,默认没有边框和样式,是专门为配合表单组件u-form而设计的,利用它可以快速实现表单验证,输入内容,下拉选择等功能。
@@ -153,7 +154,7 @@ export default {
153
154
  this.valueChange();
154
155
  } else {
155
156
  // 尝试调用u-form的验证方法
156
- uni.$u.formValidate(this, "change");
157
+ formValidate(this, "change");
157
158
  }
158
159
  /* #endif */
159
160
  this.firstChange = false;
@@ -176,7 +177,7 @@ export default {
176
177
  this.valueChange();
177
178
  } else {
178
179
  // 尝试调用u-form的验证方法
179
- uni.$u.formValidate(this, "change");
180
+ formValidate(this, "change");
180
181
  }
181
182
  /* #endif */
182
183
  this.firstChange = false;
@@ -223,13 +224,13 @@ export default {
223
224
  style.paddingLeft = "9px";
224
225
  style.paddingRight = "9px";
225
226
  }
226
- return uni.$u.deepMerge(style, uni.$u.addStyle(this.customStyle));
227
+ return deepMerge(style, addStyle(this.customStyle));
227
228
  },
228
229
  // 输入框的样式
229
230
  inputStyle() {
230
231
  const style = {
231
232
  color: this.color,
232
- fontSize: uni.$u.addUnit(this.fontSize),
233
+ fontSize: addUnit(this.fontSize),
233
234
  textAlign: this.inputAlign
234
235
  };
235
236
  return style;
@@ -261,11 +262,11 @@ export default {
261
262
  this.$emit("blur", event.detail.value);
262
263
  // H5端的blur会先于点击清除控件的点击click事件触发,导致focused
263
264
  // 瞬间为false,从而隐藏了清除控件而无法被点击到
264
- uni.$u.sleep(150).then(() => {
265
+ sleep(150).then(() => {
265
266
  this.focused = false;
266
267
  });
267
268
  // 尝试调用u-form的验证方法
268
- uni.$u.formValidate(this, "blur");
269
+ formValidate(this, "blur");
269
270
  },
270
271
  // 输入框聚焦时触发
271
272
  onFocus(event) {
@@ -295,7 +296,7 @@ export default {
295
296
  this.changeFromInner = true;
296
297
  this.$emit("change", value);
297
298
  // 尝试调用u-form的验证方法
298
- uni.$u.formValidate(this, "change");
299
+ formValidate(this, "change");
299
300
  });
300
301
  },
301
302
  // 点击清除控件
@@ -313,8 +314,8 @@ export default {
313
314
  */
314
315
  clickHandler() {
315
316
  // #ifdef APP-NVUE
316
- if (uni.$u.os() === "android") {
317
- const formItem = uni.$u.$parent.call(this, "u-form-item");
317
+ if (os() === "android") {
318
+ const formItem = $parent.call(this, "u-form-item");
318
319
  if (formItem) {
319
320
  formItem.clickHandler();
320
321
  }
@@ -68,9 +68,9 @@
68
68
  </template>
69
69
 
70
70
  <script>
71
- import props from './props.js';
72
- import mpMixin from '../../libs/mixin/mpMixin.js';
73
- import mixin from '../../libs/mixin/mixin.js';
71
+ import props from './props';
72
+ import mpMixin from '../../libs/mixin/mpMixin';
73
+ import mixin from '../../libs/mixin/mixin';
74
74
 
75
75
  /**
76
76
  * keyboard 键盘
@@ -8,9 +8,10 @@
8
8
  </template>
9
9
 
10
10
  <script>
11
- import props from './props.js';
12
- import mpMixin from '../../libs/mixin/mpMixin.js';
13
- import mixin from '../../libs/mixin/mixin.js';
11
+ import props from './props';
12
+ import mpMixin from '../../libs/mixin/mpMixin';
13
+ import mixin from '../../libs/mixin/mixin';
14
+ import { addUnit, addStyle, deepMerge } from '../../libs/function/index';
14
15
  /**
15
16
  * line 线条
16
17
  * @description 此组件一般用于显示一根线条,用于分隔内容块,有横向和竖向两种模式,且能设置0.5px线条,使用也很简单
@@ -36,18 +37,18 @@
36
37
  // 此处采用兼容分开写,兼容nvue的写法
37
38
  style.borderBottomWidth = '1px'
38
39
  style.borderBottomStyle = this.dashed ? 'dashed' : 'solid'
39
- style.width = uni.$u.addUnit(this.length)
40
+ style.width = addUnit(this.length)
40
41
  if (this.hairline) style.transform = 'scaleY(0.5)'
41
42
  } else {
42
43
  // 如果是竖向线条,边框宽度为1px,再通过transform缩小一半,就是0.5px了
43
44
  style.borderLeftWidth = '1px'
44
45
  style.borderLeftStyle = this.dashed ? 'dashed' : 'solid'
45
- style.height = uni.$u.addUnit(this.length)
46
+ style.height = addUnit(this.length)
46
47
  if (this.hairline) style.transform = 'scaleX(0.5)'
47
48
  }
48
49
 
49
50
  style.borderColor = this.color
50
- return uni.$u.deepMerge(style, uni.$u.addStyle(this.customStyle))
51
+ return deepMerge(style, addStyle(this.customStyle))
51
52
  }
52
53
  }
53
54
  }
@@ -1,14 +1,14 @@
1
1
  <template>
2
2
  <view
3
3
  class="u-line-progress"
4
- :style="[$u.addStyle(customStyle)]"
4
+ :style="[addStyle(customStyle)]"
5
5
  >
6
6
  <view
7
7
  class="u-line-progress__background"
8
8
  ref="u-line-progress__background"
9
9
  :style="[{
10
10
  backgroundColor: inactiveColor,
11
- height: $u.addUnit(height),
11
+ height: addUnit(height),
12
12
  }]"
13
13
  >
14
14
  </view>
@@ -24,9 +24,10 @@
24
24
  </template>
25
25
 
26
26
  <script>
27
- import props from './props.js';
28
- import mpMixin from '../../libs/mixin/mpMixin.js';
29
- import mixin from '../../libs/mixin/mixin.js';
27
+ import props from './props';
28
+ import mpMixin from '../../libs/mixin/mpMixin';
29
+ import mixin from '../../libs/mixin/mixin';
30
+ import { addUnit, addStyle, sleep, range } from '../../libs/function/index';
30
31
  // #ifdef APP-NVUE
31
32
  const dom = uni.requireNativePlugin('dom')
32
33
  // #endif
@@ -60,20 +61,22 @@
60
61
  let style = {}
61
62
  style.width = this.lineWidth
62
63
  style.backgroundColor = this.activeColor
63
- style.height = uni.$u.addUnit(this.height)
64
+ style.height = addUnit(this.height)
64
65
  return style
65
66
  },
66
67
  innserPercentage() {
67
68
  // 控制范围在0-100之间
68
- return uni.$u.range(0, 100, this.percentage)
69
+ return range(0, 100, this.percentage)
69
70
  }
70
71
  },
71
72
  mounted() {
72
73
  this.init()
73
74
  },
74
75
  methods: {
76
+ addStyle,
77
+ addUnit,
75
78
  init() {
76
- uni.$u.sleep(20).then(() => {
79
+ sleep(20).then(() => {
77
80
  this.resizeProgressWidth()
78
81
  })
79
82
  },
@@ -2,15 +2,15 @@
2
2
  <text
3
3
  class="u-link"
4
4
  @tap.stop="openLink"
5
- :style="[linkStyle, $u.addStyle(customStyle)]"
5
+ :style="[linkStyle, addStyle(customStyle)]"
6
6
  >{{text}}</text>
7
7
  </template>
8
8
 
9
9
  <script>
10
- import props from './props.js';
11
- import mpMixin from '../../libs/mixin/mpMixin.js';
12
- import mixin from '../../libs/mixin/mixin.js';
13
-
10
+ import props from './props';
11
+ import mpMixin from '../../libs/mixin/mpMixin';
12
+ import mixin from '../../libs/mixin/mixin';
13
+ import { addStyle, addUnit, getPx, toast } from '../../libs/function/index';
14
14
  /**
15
15
  * link 超链接
16
16
  * @description 该组件为超链接组件,在不同平台有不同表现形式:在APP平台会通过plus环境打开内置浏览器,在小程序中把链接复制到粘贴板,同时提示信息,在H5中通过window.open打开链接。
@@ -33,9 +33,9 @@
33
33
  linkStyle() {
34
34
  const style = {
35
35
  color: this.color,
36
- fontSize: uni.$u.addUnit(this.fontSize),
36
+ fontSize: addUnit(this.fontSize),
37
37
  // line-height设置为比字体大小多2px
38
- lineHeight: uni.$u.addUnit(uni.$u.getPx(this.fontSize) + 2),
38
+ lineHeight: addUnit(getPx(this.fontSize) + 2),
39
39
  textDecoration: this.underLine ? 'underline' : 'none'
40
40
  }
41
41
  // if (this.underLine) {
@@ -47,6 +47,7 @@
47
47
  },
48
48
  emits: ["click"],
49
49
  methods: {
50
+ addStyle,
50
51
  openLink() {
51
52
  // #ifdef APP-PLUS
52
53
  plus.runtime.openURL(this.href)
@@ -60,7 +61,7 @@
60
61
  success: () => {
61
62
  uni.hideToast();
62
63
  this.$nextTick(() => {
63
- uni.$u.toast(this.mpTips);
64
+ toast(this.mpTips);
64
65
  })
65
66
  }
66
67
  });
@@ -37,9 +37,10 @@
37
37
  </template>
38
38
 
39
39
  <script>
40
- import props from './props.js';
41
- import mpMixin from '../../libs/mixin/mpMixin.js';
42
- import mixin from '../../libs/mixin/mixin.js';
40
+ import props from './props';
41
+ import mpMixin from '../../libs/mixin/mpMixin';
42
+ import mixin from '../../libs/mixin/mixin';
43
+ import { addUnit, addStyle, deepMerge, sleep, sys } from '../../libs/function/index';
43
44
  // #ifdef APP-NVUE
44
45
  const dom = uni.requireNativePlugin('dom')
45
46
  // #endif
@@ -79,18 +80,17 @@
79
80
  innerScrollTop: 0,
80
81
  // vue下,scroll-view在上拉加载时的偏移值
81
82
  offset: 0,
82
- sys: uni.$u.sys()
83
+ sys: sys()
83
84
  }
84
85
  },
85
86
  computed: {
86
87
  listStyle() {
87
- const style = {},
88
- addUnit = uni.$u.addUnit
88
+ const style = {};
89
89
  if (this.width != 0) style.width = addUnit(this.width)
90
90
  if (this.height != 0) style.height = addUnit(this.height)
91
91
  // 如果没有定义列表高度,则默认使用屏幕高度
92
92
  if (!style.height) style.height = addUnit(this.sys.windowHeight, 'px')
93
- return uni.$u.deepMerge(style, uni.$u.addStyle(this.customStyle))
93
+ return deepMerge(style, addStyle(this.customStyle))
94
94
  }
95
95
  },
96
96
  provide() {
@@ -132,14 +132,14 @@
132
132
  },
133
133
  // 滚动到底部触发事件
134
134
  scrolltolower(e) {
135
- uni.$u.sleep(30).then(() => {
135
+ sleep(30).then(() => {
136
136
  this.$emit('scrolltolower')
137
137
  })
138
138
  },
139
139
  // #ifndef APP-NVUE
140
140
  // 滚动到底部时触发,非nvue有效
141
141
  scrolltoupper(e) {
142
- uni.$u.sleep(30).then(() => {
142
+ sleep(30).then(() => {
143
143
  this.$emit('scrolltoupper')
144
144
  // 这一句很重要,能绝对保证在性功能障碍的webview,滚动条到顶时,取消偏移值,让页面置顶
145
145
  this.offset = 0
@@ -16,9 +16,10 @@
16
16
  </template>
17
17
 
18
18
  <script>
19
- import props from './props.js';
20
- import mpMixin from '../../libs/mixin/mpMixin.js';
21
- import mixin from '../../libs/mixin/mixin.js';
19
+ import props from './props';
20
+ import mpMixin from '../../libs/mixin/mpMixin';
21
+ import mixin from '../../libs/mixin/mixin';
22
+ import { sys } from '../../libs/function/index';
22
23
  // #ifdef APP-NVUE
23
24
  const dom = uni.requireNativePlugin('dom')
24
25
  // #endif
@@ -38,7 +39,7 @@
38
39
  rect: {},
39
40
  index: 0,
40
41
  show: true,
41
- sys: uni.$u.sys()
42
+ sys: sys()
42
43
  }
43
44
  },
44
45
  computed: {