uview-plus 3.8.49 → 3.8.86

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 (170) hide show
  1. package/changelog.md +2043 -1827
  2. package/components/u-action-sheet/props.js +3 -1
  3. package/components/u-action-sheet/u-action-sheet.vue +1 -0
  4. package/components/u-album/props.js +3 -1
  5. package/components/u-alert/props.js +4 -2
  6. package/components/u-avatar/props.js +4 -1
  7. package/components/u-avatar-group/props.js +4 -1
  8. package/components/u-back-top/props.js +4 -1
  9. package/components/u-badge/props.js +4 -1
  10. package/components/u-barcode/u-barcode.vue +46 -15
  11. package/components/u-box/props.js +5 -2
  12. package/components/u-button/props.js +4 -1
  13. package/components/u-button/vue.scss +3 -3
  14. package/components/u-calendar/calendar.js +14 -2
  15. package/components/u-calendar/month.vue +41 -6
  16. package/components/u-calendar/props.js +63 -1
  17. package/components/u-calendar/u-calendar.vue +311 -2
  18. package/components/u-calendar-strip/props.js +3 -1
  19. package/components/u-canvas/u-canvas.vue +734 -423
  20. package/components/u-car-keyboard/props.js +3 -1
  21. package/components/u-card/props.js +3 -1
  22. package/components/u-cell/props.js +4 -1
  23. package/components/u-cell/u-cell.vue +1 -1
  24. package/components/u-cell-group/props.js +4 -1
  25. package/components/u-checkbox/props.js +4 -1
  26. package/components/u-checkbox/u-checkbox.vue +7 -3
  27. package/components/u-checkbox-group/props.js +3 -1
  28. package/components/u-circle-progress/props.js +4 -1
  29. package/components/u-code/props.js +4 -1
  30. package/components/u-code-input/props.js +4 -1
  31. package/components/u-col/props.js +4 -1
  32. package/components/u-collapse/props.js +4 -1
  33. package/components/u-collapse-item/props.js +4 -1
  34. package/components/u-color-picker/u-color-picker.vue +1 -0
  35. package/components/u-column-notice/props.js +4 -1
  36. package/components/u-count-down/props.js +4 -1
  37. package/components/u-count-to/props.js +4 -1
  38. package/components/u-cropper/u-cropper.vue +95 -51
  39. package/components/u-datetime-picker/props.js +4 -1
  40. package/components/u-divider/props.js +4 -1
  41. package/components/u-dragsort/u-dragsort.vue +2 -1
  42. package/components/u-dropdown/props.js +3 -1
  43. package/components/u-dropdown-item/props.js +3 -1
  44. package/components/u-empty/props.js +4 -1
  45. package/components/u-form/props.js +4 -1
  46. package/components/u-form-item/props.js +4 -1
  47. package/components/u-gap/props.js +4 -1
  48. package/components/u-grid/props.js +4 -1
  49. package/components/u-grid-item/props.js +4 -1
  50. package/components/u-guide/props.js +3 -1
  51. package/components/u-icon/props.js +4 -1
  52. package/components/u-icon/u-icon.vue +2 -2
  53. package/components/u-icon/upicon.ttf +0 -0
  54. package/components/u-icon/util.js +29 -7
  55. package/components/u-image/props.js +4 -1
  56. package/components/u-image/u-image.vue +280 -267
  57. package/components/u-index-anchor/props.js +4 -1
  58. package/components/u-index-item/props.js +2 -1
  59. package/components/u-index-list/props.js +4 -1
  60. package/components/u-input/props.js +3 -1
  61. package/components/u-input/u-input.vue +10 -1
  62. package/components/u-keyboard/props.js +4 -1
  63. package/components/u-line/props.js +4 -1
  64. package/components/u-line-progress/props.js +6 -3
  65. package/components/u-link/props.js +4 -1
  66. package/components/u-list/props.js +4 -1
  67. package/components/u-list-item/props.js +4 -1
  68. package/components/u-loading-icon/props.js +4 -1
  69. package/components/u-loading-page/props.js +3 -1
  70. package/components/u-loadmore/props.js +4 -1
  71. package/components/u-markdown/u-markdown.vue +45 -3
  72. package/components/u-modal/props.js +4 -1
  73. package/components/u-navbar/props.js +4 -2
  74. package/components/u-navbar/u-navbar.vue +15 -9
  75. package/components/u-no-network/props.js +4 -1
  76. package/components/u-notice-bar/props.js +4 -1
  77. package/components/u-notify/props.js +4 -1
  78. package/components/u-number-box/props.js +4 -1
  79. package/components/u-number-box/u-number-box.vue +2 -2
  80. package/components/u-number-keyboard/props.js +4 -1
  81. package/components/u-overlay/props.js +4 -1
  82. package/components/u-pagination/u-pagination.vue +60 -39
  83. package/components/u-parse/props.js +4 -1
  84. package/components/u-picker/props.js +4 -1
  85. package/components/u-picker/u-picker.vue +15 -0
  86. package/components/u-picker-column/props.js +3 -1
  87. package/components/u-popover/props.js +2 -1
  88. package/components/u-popup/props.js +4 -1
  89. package/components/u-poster/u-poster.vue +29 -14
  90. package/components/u-qrcode/qrcode.js +88 -87
  91. package/components/u-qrcode/u-qrcode.vue +138 -256
  92. package/components/u-radio/props.js +4 -1
  93. package/components/u-radio/u-radio.vue +7 -3
  94. package/components/u-radio-group/props.js +4 -1
  95. package/components/u-rate/props.js +4 -1
  96. package/components/u-read-more/props.js +4 -1
  97. package/components/u-row/props.js +4 -1
  98. package/components/u-row-notice/props.js +4 -1
  99. package/components/u-safe-bottom/props.js +2 -1
  100. package/components/u-scroll-list/props.js +4 -1
  101. package/components/u-search/props.js +3 -1
  102. package/components/u-skeleton/props.js +4 -1
  103. package/components/u-slider/props.js +3 -1
  104. package/components/u-slider/u-slider.vue +70 -28
  105. package/components/u-status-bar/props.js +4 -1
  106. package/components/u-steps/props.js +4 -1
  107. package/components/u-steps-item/props.js +4 -1
  108. package/components/u-sticky/props.js +4 -1
  109. package/components/u-sticky/u-sticky.vue +11 -0
  110. package/components/u-subsection/props.js +3 -1
  111. package/components/u-swipe-action/props.js +4 -1
  112. package/components/u-swipe-action-item/props.js +4 -1
  113. package/components/u-swipe-action-item/u-swipe-action-item.vue +14 -0
  114. package/components/u-swiper/props.js +9 -1
  115. package/components/u-swiper/swiper.js +1 -0
  116. package/components/u-swiper/u-swiper.vue +2 -0
  117. package/components/u-swiper-indicator/props.js +4 -1
  118. package/components/u-switch/props.js +4 -1
  119. package/components/u-tabbar/props.js +3 -1
  120. package/components/u-tabbar-item/props.js +4 -1
  121. package/components/u-table/props.js +3 -1
  122. package/components/u-table2/tableRow.vue +155 -69
  123. package/components/u-table2/u-table2.vue +328 -140
  124. package/components/u-tabs/props.js +4 -1
  125. package/components/u-tabs-item/props.js +3 -1
  126. package/components/u-tag/props.js +4 -1
  127. package/components/u-td/props.js +3 -1
  128. package/components/u-text/props.js +4 -1
  129. package/components/u-textarea/props.js +3 -1
  130. package/components/u-textarea/u-textarea.vue +16 -5
  131. package/components/u-th/props.js +3 -1
  132. package/components/u-toolbar/props.js +4 -1
  133. package/components/u-tooltip/props.js +10 -2
  134. package/components/u-tooltip/tooltip.js +2 -1
  135. package/components/u-tooltip/u-tooltip.vue +31 -3
  136. package/components/u-tr/props.js +3 -1
  137. package/components/u-transition/nvue-ani-map.js +75 -68
  138. package/components/u-transition/props.js +4 -1
  139. package/components/u-transition/transitionMixin.js +164 -163
  140. package/components/u-upload/props.js +4 -1
  141. package/components/u-upload/u-upload.vue +47 -40
  142. package/components/u-waterfall/u-waterfall.vue +50 -51
  143. package/index.js +65 -8
  144. package/libs/config/props.js +179 -204
  145. package/libs/css/components.scss +3 -0
  146. package/libs/function/uni-api-shims.js +29 -0
  147. package/libs/i18n/index.js +71 -36
  148. package/libs/i18n/locale-packs.js +11 -0
  149. package/libs/i18n/locales/all.js +23 -0
  150. package/libs/i18n/locales/{de.json → de.js} +1 -1
  151. package/libs/i18n/locales/{en.json → en.js} +2 -2
  152. package/libs/i18n/locales/{es.json → es.js} +1 -1
  153. package/libs/i18n/locales/{fr.json → fr.js} +2 -2
  154. package/libs/i18n/locales/{ja.json → ja.js} +1 -1
  155. package/libs/i18n/locales/{ko.json → ko.js} +1 -1
  156. package/libs/i18n/locales/{ru.json → ru.js} +1 -1
  157. package/libs/i18n/locales/{th.json → th.js} +1 -1
  158. package/libs/i18n/locales/{zh-Hans.json → zh-Hans.js} +1 -1
  159. package/libs/i18n/locales/{zh-Hant.json → zh-Hant.js} +1 -1
  160. package/libs/mixin/mixin.js +14 -4
  161. package/libs/util/gcanvas/bridge/bridge-weex.js +10 -5
  162. package/package.json +4 -5
  163. package/tsconfig.json +18 -0
  164. package/types/comps/calendar.d.ts +57 -0
  165. package/types/comps/checkbox.d.ts +12 -0
  166. package/types/comps/lineProgress.d.ts +5 -0
  167. package/types/comps/navbar.d.ts +3 -3
  168. package/types/comps/swiper.d.ts +5 -0
  169. package/types/comps/tooltip.d.ts +36 -1
  170. /package/components/u-markdown/{marked.esm.js → marked.esm.mjs} +0 -0
@@ -1,267 +1,280 @@
1
- <template>
2
- <u-transition
3
- mode="fade"
4
- :show="show"
5
- :style="transStyle"
6
- :duration="fade ? 1000 : 0"
7
- >
8
- <view
9
- class="u-image box-border"
10
- @tap="onClick"
11
- :style="[wrapStyle, backgroundStyle]"
12
- >
13
- <image
14
- v-if="!isError"
15
- :src="src"
16
- :mode="mode"
17
- @error="onErrorHandler"
18
- @load="onLoadHandler"
19
- :show-menu-by-longpress="showMenuByLongpress"
20
- :lazy-load="lazyLoad"
21
- class="u-image__image"
22
- :style="{
23
- width: addUnit(width),
24
- height: addUnit(height),
25
- borderRadius: shape == 'circle' ? '10000px' : addUnit(radius)
26
- }"
27
- ></image>
28
- <view
29
- v-if="showLoading && loading"
30
- class="u-image__loading"
31
- :style="{
32
- borderRadius: shape == 'circle' ? '50%' : addUnit(radius),
33
- backgroundColor: this.bgColor,
34
- width: addUnit(width),
35
- height: addUnit(height)
36
- }"
37
- >
38
- <slot name="loading">
39
- <up-icon
40
- :name="loadingIcon"
41
- ></up-icon>
42
- </slot>
43
- </view>
44
- <view
45
- v-if="showError && isError && !loading"
46
- class="u-image__error"
47
- :style="{
48
- borderRadius: shape == 'circle' ? '50%' : addUnit(radius),
49
- backgroundColor: this.bgColor,
50
- width: addUnit(width),
51
- height: addUnit(height)
52
- }"
53
- >
54
- <slot name="error">
55
- <up-icon
56
- :name="errorIcon"
57
- ></up-icon>
58
- </slot>
59
- </view>
60
- </view>
61
- </u-transition>
62
- </template>
63
-
64
- <script>
65
- import { props } from './props';
66
- import { mpMixin } from '../../libs/mixin/mpMixin';
67
- import { mixin } from '../../libs/mixin/mixin';
68
- import { addUnit, addStyle, deepMerge } from '../../libs/function/index';
69
- /**
70
- * Image 图片
71
- * @description 此组件为uni-app的image组件的加强版,在继承了原有功能外,还支持淡入动画、加载中、加载失败提示、圆角值和形状等。
72
- * @tutorial https://uview-plus.jiangruyi.com/components/image.html
73
- * @property {String} src 图片地址
74
- * @property {String} mode 裁剪模式,见官网说明 (默认 'aspectFill' )
75
- * @property {String | Number} width 宽度,单位任意,如果为数值,则为px单位 (默认 '300' )
76
- * @property {String | Number} height 高度,单位任意,如果为数值,则为px单位 (默认 '225' )
77
- * @property {String} shape 图片形状,circle-圆形,square-方形 (默认 'square' )
78
- * @property {String | Number} radius 圆角值,单位任意,如果为数值,则为px单位 (默认 0 )
79
- * @property {Boolean} lazyLoad 是否懒加载,仅微信小程序、App、百度小程序、字节跳动小程序有效 (默认 true )
80
- * @property {Boolean} showMenuByLongpress 是否开启长按图片显示识别小程序码菜单,仅微信小程序有效 (默认 true )
81
- * @property {String} loadingIcon 加载中的图标,或者小图片 (默认 'photo' )
82
- * @property {String} errorIcon 加载失败的图标,或者小图片 (默认 'error-circle' )
83
- * @property {Boolean} showLoading 是否显示加载中的图标或者自定义的slot (默认 true )
84
- * @property {Boolean} showError 是否显示加载错误的图标或者自定义的slot (默认 true )
85
- * @property {Boolean} fade 是否需要淡入效果 (默认 true )
86
- * @property {Boolean} webp 只支持网络资源,只对微信小程序有效 (默认 false )
87
- * @property {String | Number} duration 搭配fade参数的过渡时间,单位ms (默认 500 )
88
- * @property {String} bgColor 背景颜色,用于深色页面加载图片时,为了和背景色融合 (默认 '#f3f4f6' )
89
- * @property {Object} customStyle 定义需要用到的外部样式
90
- * @event {Function} click 点击图片时触发
91
- * @event {Function} error 图片加载失败时触发
92
- * @event {Function} load 图片加载成功时触发
93
- * @example <u-image width="100%" height="300px" :src="src"></u-image>
94
- */
95
- export default {
96
- name: 'u-image',
97
- mixins: [mpMixin, mixin, props],
98
- data() {
99
- return {
100
- // 图片是否加载错误,如果是,则显示错误占位图
101
- isError: false,
102
- // 初始化组件时,默认为加载中状态
103
- loading: true,
104
- // 不透明度,为了实现淡入淡出的效果
105
- opacity: 1,
106
- // 过渡时间,因为props的值无法修改,故需要一个中间值
107
- durationTime: this.duration,
108
- // 图片加载完成时,去掉背景颜色,因为如果是png图片,就会显示灰色的背景
109
- backgroundStyle: {},
110
- // 用于fade模式的控制组件显示与否
111
- show: false
112
- };
113
- },
114
- watch: {
115
- src: {
116
- immediate: true,
117
- handler(n) {
118
- if (!n) {
119
- // 如果传入null或者'',或者false,或者undefined,标记为错误状态
120
- this.isError = true
121
- } else {
122
- this.isError = false;
123
- this.loading = true;
124
- }
125
- }
126
- }
127
- },
128
- computed: {
129
- transStyle() {
130
- let style = {};
131
- // 通过调用addUnit()方法,如果有单位,如百分比,px单位等,直接返回,如果是纯粹的数值,则加上rpx单位
132
- // #ifdef APP-NVUE
133
- style.width = addUnit(this.width);
134
- style.height = addUnit(this.height);
135
- // #endif
136
- // #ifndef APP-NVUE
137
- if (this.loading || this.isError || this.width == '100%' || this.mode != 'heightFix') {
138
- style.width = addUnit(this.width);
139
- } else {
140
- style.width = 'fit-content';
141
- }
142
- if (this.loading || this.isError || this.height == '100%' || this.mode != 'widthFix') {
143
- style.height = addUnit(this.height);
144
- } else {
145
- style.height = 'fit-content';
146
- }
147
- // #endif
148
- return style;
149
- },
150
- wrapStyle() {
151
- let style = {};
152
- // 通过调用addUnit()方法,如果有单位,如百分比,px单位等,直接返回,如果是纯粹的数值,则加上rpx单位
153
- // #ifdef APP-NVUE
154
- style.width = addUnit(this.width);
155
- style.height = addUnit(this.height);
156
- // #endif
157
- // #ifndef APP-NVUE
158
- if (this.loading || this.isError || this.width == '100%' || this.mode != 'heightFix') {
159
- style.width = addUnit(this.width);
160
- } else {
161
- style.width = 'fit-content';
162
- }
163
- if (this.loading || this.isError || this.height == '100%' || this.mode != 'widthFix') {
164
- style.height = addUnit(this.height);
165
- } else {
166
- style.height = 'fit-content';
167
- }
168
- // #endif
169
- // 如果是显示圆形,设置一个很多的半径值即可
170
- style.borderRadius = this.shape == 'circle' ? '10000px' : addUnit(this.radius)
171
- // 如果设置圆角,必须要有hidden,否则可能圆角无效
172
- style.overflow = this.radius > 0 ? 'hidden' : 'visible'
173
- // if (this.fade) {
174
- // style.opacity = this.opacity
175
- // // nvue下,这几个属性必须要分开写
176
- // style.transitionDuration = `${this.durationTime}ms`
177
- // style.transitionTimingFunction = 'ease-in-out'
178
- // style.transitionProperty = 'opacity'
179
- // }
180
- return deepMerge(style, addStyle(this.customStyle));
181
-
182
- }
183
- },
184
- mounted() {
185
- this.show = true
186
- },
187
- emits: ['click', 'error', 'load'],
188
- methods: {
189
- addUnit,
190
- // 点击图片
191
- onClick(e) {
192
- this.$emit('click', e)
193
- },
194
- // 图片加载失败
195
- onErrorHandler(err) {
196
- this.loading = false
197
- this.isError = true
198
- this.$emit('error', err)
199
- },
200
- // 图片加载完成,标记loading结束
201
- onLoadHandler(event) {
202
- this.loading = false
203
- this.isError = false
204
- this.$emit('load', event)
205
- this.removeBgColor()
206
- // 如果不需要动画效果,就不执行下方代码,同时移除加载时的背景颜色
207
- // 否则无需fade效果时,png图片依然能看到下方的背景色
208
- // if (!this.fade) return this.removeBgColor();
209
- // // 原来opacity为1(不透明,是为了显示占位图),改成0(透明,意味着该元素显示的是背景颜色,默认的灰色),再改成1,是为了获得过渡效果
210
- // this.opacity = 0;
211
- // // 这里设置为0,是为了图片展示到背景全透明这个过程时间为0,延时之后延时之后重新设置为duration,是为了获得背景透明(灰色)
212
- // // 到图片展示的过程中的淡入效果
213
- // this.durationTime = 0;
214
- // // 延时50ms,否则在浏览器H5,过渡效果无效
215
- // setTimeout(() => {
216
- // this.durationTime = this.duration;
217
- // this.opacity = 1;
218
- // setTimeout(() => {
219
- // this.removeBgColor();
220
- // }, this.durationTime);
221
- // }, 50);
222
- },
223
- // 移除图片的背景色
224
- removeBgColor() {
225
- // 淡入动画过渡完成后,将背景设置为透明色,否则png图片会看到灰色的背景
226
- // this.backgroundStyle = {
227
- // backgroundColor: this.bgColor || '#ffffff'
228
- // };
229
- }
230
- }
231
- };
232
- </script>
233
-
234
- <style lang="scss" scoped>
235
- $u-image-error-top:0px !default;
236
- $u-image-error-left:0px !default;
237
- $u-image-error-width:100% !default;
238
- $u-image-error-hight:100% !default;
239
- $u-image-error-background-color:$u-bg-color !default;
240
- $u-image-error-color:$u-tips-color !default;
241
- $u-image-error-font-size: 46rpx !default;
242
-
243
- .u-image {
244
- position: relative;
245
- transition: opacity 0.5s ease-in-out;
246
-
247
- &__image {
248
- width: 100%;
249
- height: 100%;
250
- }
251
-
252
- &__loading,
253
- &__error {
254
- position: absolute;
255
- top: $u-image-error-top;
256
- left: $u-image-error-left;
257
- width: $u-image-error-width;
258
- height: $u-image-error-hight;
259
- @include flex;
260
- align-items: center;
261
- justify-content: center;
262
- background-color: $u-image-error-background-color;
263
- color: $u-image-error-color;
264
- font-size: $u-image-error-font-size;
265
- }
266
- }
267
- </style>
1
+ <template>
2
+ <u-transition
3
+ mode="fade"
4
+ :show="show"
5
+ :style="transStyle"
6
+ :duration="fade ? 1000 : 0"
7
+ >
8
+ <view
9
+ class="u-image box-border"
10
+ @tap="onClick"
11
+ :style="[wrapStyle, backgroundStyle]"
12
+ >
13
+ <image
14
+ v-if="!isError"
15
+ :src="src"
16
+ :mode="mode"
17
+ @error="onErrorHandler"
18
+ @load="onLoadHandler"
19
+ :show-menu-by-longpress="showMenuByLongpress"
20
+ :lazy-load="lazyLoad"
21
+ class="u-image__image"
22
+ :style="{
23
+ width: addUnit(width),
24
+ height: addUnit(height),
25
+ borderRadius: shape == 'circle' ? '10000px' : addUnit(radius)
26
+ }"
27
+ ></image>
28
+ <view
29
+ v-if="showLoading && loading"
30
+ class="u-image__loading"
31
+ :style="{
32
+ borderRadius: shape == 'circle' ? '50%' : addUnit(radius),
33
+ backgroundColor: this.bgColor,
34
+ width: addUnit(width),
35
+ height: addUnit(height)
36
+ }"
37
+ >
38
+ <slot name="loading">
39
+ <up-icon
40
+ :name="loadingIcon"
41
+ ></up-icon>
42
+ </slot>
43
+ </view>
44
+ <view
45
+ v-if="showError && isError && !loading"
46
+ class="u-image__error"
47
+ :style="{
48
+ borderRadius: shape == 'circle' ? '50%' : addUnit(radius),
49
+ backgroundColor: this.bgColor,
50
+ width: addUnit(width),
51
+ height: addUnit(height)
52
+ }"
53
+ >
54
+ <slot name="error">
55
+ <up-icon
56
+ :name="errorIcon"
57
+ ></up-icon>
58
+ </slot>
59
+ </view>
60
+ </view>
61
+ </u-transition>
62
+ </template>
63
+
64
+ <script>
65
+ import { props } from './props';
66
+ import { mpMixin } from '../../libs/mixin/mpMixin';
67
+ import { mixin } from '../../libs/mixin/mixin';
68
+ import { addUnit, addStyle, deepMerge } from '../../libs/function/index';
69
+ /**
70
+ * Image 图片
71
+ * @description 此组件为uni-app的image组件的加强版,在继承了原有功能外,还支持淡入动画、加载中、加载失败提示、圆角值和形状等。
72
+ * @tutorial https://uview-plus.jiangruyi.com/components/image.html
73
+ * @property {String} src 图片地址
74
+ * @property {String} mode 裁剪模式,见官网说明 (默认 'aspectFill' )
75
+ * @property {String | Number} width 宽度,单位任意,如果为数值,则为px单位 (默认 '300' )
76
+ * @property {String | Number} height 高度,单位任意,如果为数值,则为px单位 (默认 '225' )
77
+ * @property {String} shape 图片形状,circle-圆形,square-方形 (默认 'square' )
78
+ * @property {String | Number} radius 圆角值,单位任意,如果为数值,则为px单位 (默认 0 )
79
+ * @property {Boolean} lazyLoad 是否懒加载,仅微信小程序、App、百度小程序、字节跳动小程序有效 (默认 true )
80
+ * @property {Boolean} showMenuByLongpress 是否开启长按图片显示识别小程序码菜单,仅微信小程序有效 (默认 true )
81
+ * @property {String} loadingIcon 加载中的图标,或者小图片 (默认 'photo' )
82
+ * @property {String} errorIcon 加载失败的图标,或者小图片 (默认 'error-circle' )
83
+ * @property {Boolean} showLoading 是否显示加载中的图标或者自定义的slot (默认 true )
84
+ * @property {Boolean} showError 是否显示加载错误的图标或者自定义的slot (默认 true )
85
+ * @property {Boolean} fade 是否需要淡入效果 (默认 true )
86
+ * @property {Boolean} webp 只支持网络资源,只对微信小程序有效 (默认 false )
87
+ * @property {String | Number} duration 搭配fade参数的过渡时间,单位ms (默认 500 )
88
+ * @property {String} bgColor 背景颜色,用于深色页面加载图片时,为了和背景色融合 (默认 '#f3f4f6' )
89
+ * @property {Object} customStyle 定义需要用到的外部样式
90
+ * @event {Function} click 点击图片时触发
91
+ * @event {Function} error 图片加载失败时触发
92
+ * @event {Function} load 图片加载成功时触发
93
+ * @example <u-image width="100%" height="300px" :src="src"></u-image>
94
+ */
95
+ export default {
96
+ name: 'u-image',
97
+ mixins: [mpMixin, mixin, props],
98
+ data() {
99
+ return {
100
+ // 图片是否加载错误,如果是,则显示错误占位图
101
+ isError: false,
102
+ // 初始化组件时,默认为加载中状态
103
+ loading: true,
104
+ // 不透明度,为了实现淡入淡出的效果
105
+ opacity: 1,
106
+ // 过渡时间,因为props的值无法修改,故需要一个中间值
107
+ durationTime: this.duration,
108
+ // 图片加载完成时,去掉背景颜色,因为如果是png图片,就会显示灰色的背景
109
+ backgroundStyle: {},
110
+ // 用于fade模式的控制组件显示与否
111
+ show: false
112
+ };
113
+ },
114
+ watch: {
115
+ src: {
116
+ immediate: true,
117
+ handler(n) {
118
+ if (!n) {
119
+ // 如果传入null或者'',或者false,或者undefined,标记为错误状态
120
+ this.isError = true
121
+ } else {
122
+ this.isError = false;
123
+ this.loading = true;
124
+ }
125
+ }
126
+ }
127
+ },
128
+ computed: {
129
+ resolvedSizeStyle() {
130
+ const style = {};
131
+ // #ifdef APP-NVUE
132
+ style.width = addUnit(this.width);
133
+ style.height = addUnit(this.height);
134
+ // #endif
135
+ // #ifndef APP-NVUE
136
+ // widthFix/heightFix 加载完成后用 fit-content 跟随图片比例;其余模式固定宽高
137
+ if (this.loading || this.isError || this.width == '100%' || this.mode != 'heightFix') {
138
+ style.width = addUnit(this.width);
139
+ } else {
140
+ style.width = 'fit-content';
141
+ }
142
+ if (this.loading || this.isError || this.height == '100%' || this.mode != 'widthFix') {
143
+ style.height = addUnit(this.height);
144
+ } else {
145
+ style.height = 'fit-content';
146
+ }
147
+ // #endif
148
+ return style;
149
+ },
150
+ transStyle() {
151
+ return {
152
+ ...this.resolvedSizeStyle,
153
+ // flex 行布局下默认 shrink=1 会把固定宽图片压成细条
154
+ flexShrink: 0,
155
+ boxSizing: 'border-box',
156
+ maxWidth: '100%'
157
+ };
158
+ },
159
+ wrapStyle() {
160
+ let style = {
161
+ ...this.resolvedSizeStyle,
162
+ flexShrink: 0,
163
+ boxSizing: 'border-box',
164
+ maxWidth: '100%'
165
+ };
166
+ // 固定尺寸时用 minWidth/minHeight 抵抗 flex 压缩;百分比宽度不设 minWidth 以免撑破父级
167
+ const widthText = String(style.width || '')
168
+ const heightText = String(style.height || '')
169
+ if (widthText && widthText !== 'fit-content' && !widthText.includes('%')) {
170
+ style.minWidth = widthText
171
+ }
172
+ if (heightText && heightText !== 'fit-content' && !heightText.includes('%')) {
173
+ style.minHeight = heightText
174
+ }
175
+ // 如果是显示圆形,设置一个很多的半径值即可
176
+ style.borderRadius = this.shape == 'circle' ? '10000px' : addUnit(this.radius)
177
+ // radius 可能是 "12px" 字符串,不能用 > 0 判断
178
+ const radiusNumber = Number(String(this.radius ?? '').replace(/[^\d.-]/g, ''))
179
+ const hasRadius = this.shape == 'circle' || (!Number.isNaN(radiusNumber) && radiusNumber > 0)
180
+ // 裁剪圆角 / aspectFill 时需要 hidden,避免内容溢出成细条错位
181
+ style.overflow = hasRadius || this.mode === 'aspectFill' || this.mode === 'aspectFit' ? 'hidden' : 'visible'
182
+ // if (this.fade) {
183
+ // style.opacity = this.opacity
184
+ // // nvue下,这几个属性必须要分开写
185
+ // style.transitionDuration = `${this.durationTime}ms`
186
+ // style.transitionTimingFunction = 'ease-in-out'
187
+ // style.transitionProperty = 'opacity'
188
+ // }
189
+ return deepMerge(style, addStyle(this.customStyle));
190
+
191
+ }
192
+ },
193
+ mounted() {
194
+ this.show = true
195
+ },
196
+ emits: ['click', 'error', 'load'],
197
+ methods: {
198
+ addUnit,
199
+ // 点击图片
200
+ onClick(e) {
201
+ this.$emit('click', e)
202
+ },
203
+ // 图片加载失败
204
+ onErrorHandler(err) {
205
+ this.loading = false
206
+ this.isError = true
207
+ this.$emit('error', err)
208
+ },
209
+ // 图片加载完成,标记loading结束
210
+ onLoadHandler(event) {
211
+ this.loading = false
212
+ this.isError = false
213
+ this.$emit('load', event)
214
+ this.removeBgColor()
215
+ // 如果不需要动画效果,就不执行下方代码,同时移除加载时的背景颜色
216
+ // 否则无需fade效果时,png图片依然能看到下方的背景色
217
+ // if (!this.fade) return this.removeBgColor();
218
+ // // 原来opacity为1(不透明,是为了显示占位图),改成0(透明,意味着该元素显示的是背景颜色,默认的灰色),再改成1,是为了获得过渡效果
219
+ // this.opacity = 0;
220
+ // // 这里设置为0,是为了图片展示到背景全透明这个过程时间为0,延时之后延时之后重新设置为duration,是为了获得背景透明(灰色)
221
+ // // 到图片展示的过程中的淡入效果
222
+ // this.durationTime = 0;
223
+ // // 延时50ms,否则在浏览器H5,过渡效果无效
224
+ // setTimeout(() => {
225
+ // this.durationTime = this.duration;
226
+ // this.opacity = 1;
227
+ // setTimeout(() => {
228
+ // this.removeBgColor();
229
+ // }, this.durationTime);
230
+ // }, 50);
231
+ },
232
+ // 移除图片的背景色
233
+ removeBgColor() {
234
+ // 淡入动画过渡完成后,将背景设置为透明色,否则png图片会看到灰色的背景
235
+ // this.backgroundStyle = {
236
+ // backgroundColor: this.bgColor || '#ffffff'
237
+ // };
238
+ }
239
+ }
240
+ };
241
+ </script>
242
+
243
+ <style lang="scss" scoped>
244
+ $u-image-error-top:0px !default;
245
+ $u-image-error-left:0px !default;
246
+ $u-image-error-width:100% !default;
247
+ $u-image-error-hight:100% !default;
248
+ $u-image-error-background-color:$u-bg-color !default;
249
+ $u-image-error-color:$u-tips-color !default;
250
+ $u-image-error-font-size: 46rpx !default;
251
+
252
+ .u-image {
253
+ position: relative;
254
+ transition: opacity 0.5s ease-in-out;
255
+ flex-shrink: 0;
256
+ max-width: 100%;
257
+ box-sizing: border-box;
258
+
259
+ &__image {
260
+ width: 100%;
261
+ height: 100%;
262
+ display: block;
263
+ }
264
+
265
+ &__loading,
266
+ &__error {
267
+ position: absolute;
268
+ top: $u-image-error-top;
269
+ left: $u-image-error-left;
270
+ width: $u-image-error-width;
271
+ height: $u-image-error-hight;
272
+ @include flex;
273
+ align-items: center;
274
+ justify-content: center;
275
+ background-color: $u-image-error-background-color;
276
+ color: $u-image-error-color;
277
+ font-size: $u-image-error-font-size;
278
+ }
279
+ }
280
+ </style>
@@ -1,5 +1,8 @@
1
1
  import { defineMixin } from '../../libs/vue'
2
- import defProps from '../../libs/config/props.js'
2
+ import IndexAnchorDefaultProps from './indexAnchor'
3
+ import { registerComponentProps } from '../../libs/config/props.js'
4
+
5
+ const defProps = registerComponentProps(IndexAnchorDefaultProps)
3
6
  export const props = defineMixin({
4
7
  props: {
5
8
  // 列表锚点文本内容
@@ -1,6 +1,7 @@
1
1
  import { defineMixin } from '../../libs/vue'
2
- import defProps from '../../libs/config/props.js'
2
+ import { registerComponentProps } from '../../libs/config/props.js'
3
3
 
4
+ const defProps = registerComponentProps({ indexItem: {} })
4
5
  export const props = defineMixin({
5
6
  props: {
6
7
 
@@ -1,5 +1,8 @@
1
1
  import { defineMixin } from '../../libs/vue'
2
- import defProps from '../../libs/config/props.js'
2
+ import IndexListDefaultProps from './indexList'
3
+ import { registerComponentProps } from '../../libs/config/props.js'
4
+
5
+ const defProps = registerComponentProps(IndexListDefaultProps)
3
6
  export const props = defineMixin({
4
7
  props: {
5
8
  // 右边锚点非激活的颜色
@@ -1,6 +1,8 @@
1
1
  import { defineMixin } from '../../libs/vue'
2
- import defProps from '../../libs/config/props.js'
2
+ import InputDefaultProps from './input'
3
+ import { registerComponentProps } from '../../libs/config/props.js'
3
4
 
5
+ const defProps = registerComponentProps(InputDefaultProps)
4
6
  export const props = defineMixin({
5
7
  props: {
6
8
  // #ifdef VUE3
@@ -150,6 +150,8 @@ export default {
150
150
  firstChange: true,
151
151
  // value绑定值的变化是由内部还是外部引起的
152
152
  changeFromInner: false,
153
+ // 记录blur时原生输入框的值,用于识别blur阶段的外部格式化回流
154
+ blurValue: null,
153
155
  // 过滤处理方法
154
156
  innerFormatter: value => value,
155
157
  showPassword: false
@@ -166,11 +168,17 @@ export default {
166
168
  immediate: true,
167
169
  handler(newVal, oldVal) {
168
170
  // console.log(newVal, oldVal)
169
- if (this.changeFromInner || this.innerValue === newVal) {
171
+ const isBlurFormattedValue =
172
+ this.blurValue !== null &&
173
+ newVal !== this.blurValue &&
174
+ newVal !== this.innerValue;
175
+ if ((this.changeFromInner && !isBlurFormattedValue) || this.innerValue === newVal) {
170
176
  this.changeFromInner = false; // 重要否则会出现双向绑定失效问题https://github.com/ijry/uview-plus/issues/419
177
+ this.blurValue = null;
171
178
  return;
172
179
  }
173
180
  this.innerValue = newVal;
181
+ this.blurValue = null;
174
182
  // 在H5中,外部value变化后,修改input中的值,不会触发@input事件,此时手动调用值变化方法
175
183
  if (
176
184
  this.firstChange === false &&
@@ -302,6 +310,7 @@ export default {
302
310
  },
303
311
  // 输入框失去焦点时触发
304
312
  onBlur(event) {
313
+ this.blurValue = event?.detail?.value;
305
314
  this.$emit("blur", event.detail.value);
306
315
  // H5端的blur会先于点击清除控件的点击click事件触发,导致focused
307
316
  // 瞬间为false,从而隐藏了清除控件而无法被点击到
@@ -1,5 +1,8 @@
1
1
  import { defineMixin } from '../../libs/vue'
2
- import defProps from '../../libs/config/props.js'
2
+ import KeyboardDefaultProps from './keyboard'
3
+ import { registerComponentProps } from '../../libs/config/props.js'
4
+
5
+ const defProps = registerComponentProps(KeyboardDefaultProps)
3
6
  export const props = defineMixin({
4
7
  props: {
5
8
  // 键盘的类型,number-数字键盘,card-身份证键盘,car-车牌号键盘
@@ -1,5 +1,8 @@
1
1
  import { defineMixin } from '../../libs/vue'
2
- import defProps from '../../libs/config/props.js'
2
+ import LineDefaultProps from './line'
3
+ import { registerComponentProps } from '../../libs/config/props.js'
4
+
5
+ const defProps = registerComponentProps(LineDefaultProps)
3
6
  export const props = defineMixin({
4
7
  props: {
5
8
  color: {