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.
- package/changelog.md +2043 -1827
- package/components/u-action-sheet/props.js +3 -1
- package/components/u-action-sheet/u-action-sheet.vue +1 -0
- package/components/u-album/props.js +3 -1
- package/components/u-alert/props.js +4 -2
- package/components/u-avatar/props.js +4 -1
- package/components/u-avatar-group/props.js +4 -1
- package/components/u-back-top/props.js +4 -1
- package/components/u-badge/props.js +4 -1
- package/components/u-barcode/u-barcode.vue +46 -15
- package/components/u-box/props.js +5 -2
- package/components/u-button/props.js +4 -1
- package/components/u-button/vue.scss +3 -3
- package/components/u-calendar/calendar.js +14 -2
- package/components/u-calendar/month.vue +41 -6
- package/components/u-calendar/props.js +63 -1
- package/components/u-calendar/u-calendar.vue +311 -2
- package/components/u-calendar-strip/props.js +3 -1
- package/components/u-canvas/u-canvas.vue +734 -423
- package/components/u-car-keyboard/props.js +3 -1
- package/components/u-card/props.js +3 -1
- package/components/u-cell/props.js +4 -1
- package/components/u-cell/u-cell.vue +1 -1
- package/components/u-cell-group/props.js +4 -1
- package/components/u-checkbox/props.js +4 -1
- package/components/u-checkbox/u-checkbox.vue +7 -3
- package/components/u-checkbox-group/props.js +3 -1
- package/components/u-circle-progress/props.js +4 -1
- package/components/u-code/props.js +4 -1
- package/components/u-code-input/props.js +4 -1
- package/components/u-col/props.js +4 -1
- package/components/u-collapse/props.js +4 -1
- package/components/u-collapse-item/props.js +4 -1
- package/components/u-color-picker/u-color-picker.vue +1 -0
- package/components/u-column-notice/props.js +4 -1
- package/components/u-count-down/props.js +4 -1
- package/components/u-count-to/props.js +4 -1
- package/components/u-cropper/u-cropper.vue +95 -51
- package/components/u-datetime-picker/props.js +4 -1
- package/components/u-divider/props.js +4 -1
- package/components/u-dragsort/u-dragsort.vue +2 -1
- package/components/u-dropdown/props.js +3 -1
- package/components/u-dropdown-item/props.js +3 -1
- package/components/u-empty/props.js +4 -1
- package/components/u-form/props.js +4 -1
- package/components/u-form-item/props.js +4 -1
- package/components/u-gap/props.js +4 -1
- package/components/u-grid/props.js +4 -1
- package/components/u-grid-item/props.js +4 -1
- package/components/u-guide/props.js +3 -1
- package/components/u-icon/props.js +4 -1
- package/components/u-icon/u-icon.vue +2 -2
- package/components/u-icon/upicon.ttf +0 -0
- package/components/u-icon/util.js +29 -7
- package/components/u-image/props.js +4 -1
- package/components/u-image/u-image.vue +280 -267
- package/components/u-index-anchor/props.js +4 -1
- package/components/u-index-item/props.js +2 -1
- package/components/u-index-list/props.js +4 -1
- package/components/u-input/props.js +3 -1
- package/components/u-input/u-input.vue +10 -1
- package/components/u-keyboard/props.js +4 -1
- package/components/u-line/props.js +4 -1
- package/components/u-line-progress/props.js +6 -3
- package/components/u-link/props.js +4 -1
- package/components/u-list/props.js +4 -1
- package/components/u-list-item/props.js +4 -1
- package/components/u-loading-icon/props.js +4 -1
- package/components/u-loading-page/props.js +3 -1
- package/components/u-loadmore/props.js +4 -1
- package/components/u-markdown/u-markdown.vue +45 -3
- package/components/u-modal/props.js +4 -1
- package/components/u-navbar/props.js +4 -2
- package/components/u-navbar/u-navbar.vue +15 -9
- package/components/u-no-network/props.js +4 -1
- package/components/u-notice-bar/props.js +4 -1
- package/components/u-notify/props.js +4 -1
- package/components/u-number-box/props.js +4 -1
- package/components/u-number-box/u-number-box.vue +2 -2
- package/components/u-number-keyboard/props.js +4 -1
- package/components/u-overlay/props.js +4 -1
- package/components/u-pagination/u-pagination.vue +60 -39
- package/components/u-parse/props.js +4 -1
- package/components/u-picker/props.js +4 -1
- package/components/u-picker/u-picker.vue +15 -0
- package/components/u-picker-column/props.js +3 -1
- package/components/u-popover/props.js +2 -1
- package/components/u-popup/props.js +4 -1
- package/components/u-poster/u-poster.vue +29 -14
- package/components/u-qrcode/qrcode.js +88 -87
- package/components/u-qrcode/u-qrcode.vue +138 -256
- package/components/u-radio/props.js +4 -1
- package/components/u-radio/u-radio.vue +7 -3
- package/components/u-radio-group/props.js +4 -1
- package/components/u-rate/props.js +4 -1
- package/components/u-read-more/props.js +4 -1
- package/components/u-row/props.js +4 -1
- package/components/u-row-notice/props.js +4 -1
- package/components/u-safe-bottom/props.js +2 -1
- package/components/u-scroll-list/props.js +4 -1
- package/components/u-search/props.js +3 -1
- package/components/u-skeleton/props.js +4 -1
- package/components/u-slider/props.js +3 -1
- package/components/u-slider/u-slider.vue +70 -28
- package/components/u-status-bar/props.js +4 -1
- package/components/u-steps/props.js +4 -1
- package/components/u-steps-item/props.js +4 -1
- package/components/u-sticky/props.js +4 -1
- package/components/u-sticky/u-sticky.vue +11 -0
- package/components/u-subsection/props.js +3 -1
- package/components/u-swipe-action/props.js +4 -1
- package/components/u-swipe-action-item/props.js +4 -1
- package/components/u-swipe-action-item/u-swipe-action-item.vue +14 -0
- package/components/u-swiper/props.js +9 -1
- package/components/u-swiper/swiper.js +1 -0
- package/components/u-swiper/u-swiper.vue +2 -0
- package/components/u-swiper-indicator/props.js +4 -1
- package/components/u-switch/props.js +4 -1
- package/components/u-tabbar/props.js +3 -1
- package/components/u-tabbar-item/props.js +4 -1
- package/components/u-table/props.js +3 -1
- package/components/u-table2/tableRow.vue +155 -69
- package/components/u-table2/u-table2.vue +328 -140
- package/components/u-tabs/props.js +4 -1
- package/components/u-tabs-item/props.js +3 -1
- package/components/u-tag/props.js +4 -1
- package/components/u-td/props.js +3 -1
- package/components/u-text/props.js +4 -1
- package/components/u-textarea/props.js +3 -1
- package/components/u-textarea/u-textarea.vue +16 -5
- package/components/u-th/props.js +3 -1
- package/components/u-toolbar/props.js +4 -1
- package/components/u-tooltip/props.js +10 -2
- package/components/u-tooltip/tooltip.js +2 -1
- package/components/u-tooltip/u-tooltip.vue +31 -3
- package/components/u-tr/props.js +3 -1
- package/components/u-transition/nvue-ani-map.js +75 -68
- package/components/u-transition/props.js +4 -1
- package/components/u-transition/transitionMixin.js +164 -163
- package/components/u-upload/props.js +4 -1
- package/components/u-upload/u-upload.vue +47 -40
- package/components/u-waterfall/u-waterfall.vue +50 -51
- package/index.js +65 -8
- package/libs/config/props.js +179 -204
- package/libs/css/components.scss +3 -0
- package/libs/function/uni-api-shims.js +29 -0
- package/libs/i18n/index.js +71 -36
- package/libs/i18n/locale-packs.js +11 -0
- package/libs/i18n/locales/all.js +23 -0
- package/libs/i18n/locales/{de.json → de.js} +1 -1
- package/libs/i18n/locales/{en.json → en.js} +2 -2
- package/libs/i18n/locales/{es.json → es.js} +1 -1
- package/libs/i18n/locales/{fr.json → fr.js} +2 -2
- package/libs/i18n/locales/{ja.json → ja.js} +1 -1
- package/libs/i18n/locales/{ko.json → ko.js} +1 -1
- package/libs/i18n/locales/{ru.json → ru.js} +1 -1
- package/libs/i18n/locales/{th.json → th.js} +1 -1
- package/libs/i18n/locales/{zh-Hans.json → zh-Hans.js} +1 -1
- package/libs/i18n/locales/{zh-Hant.json → zh-Hant.js} +1 -1
- package/libs/mixin/mixin.js +14 -4
- package/libs/util/gcanvas/bridge/bridge-weex.js +10 -5
- package/package.json +4 -5
- package/tsconfig.json +18 -0
- package/types/comps/calendar.d.ts +57 -0
- package/types/comps/checkbox.d.ts +12 -0
- package/types/comps/lineProgress.d.ts +5 -0
- package/types/comps/navbar.d.ts +3 -3
- package/types/comps/swiper.d.ts +5 -0
- package/types/comps/tooltip.d.ts +36 -1
- /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
|
-
|
|
130
|
-
|
|
131
|
-
//
|
|
132
|
-
|
|
133
|
-
style.
|
|
134
|
-
|
|
135
|
-
// #
|
|
136
|
-
//
|
|
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
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
//
|
|
176
|
-
|
|
177
|
-
//
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
this.
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
//
|
|
216
|
-
//
|
|
217
|
-
//
|
|
218
|
-
//
|
|
219
|
-
//
|
|
220
|
-
//
|
|
221
|
-
//
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
//
|
|
226
|
-
//
|
|
227
|
-
//
|
|
228
|
-
//
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
|
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: {
|