uview-pro 0.0.1
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 +6 -0
- package/components/u-action-sheet/u-action-sheet.vue +205 -0
- package/components/u-alert-tips/u-alert-tips.vue +241 -0
- package/components/u-avatar/u-avatar.vue +220 -0
- package/components/u-avatar-cropper/u-avatar-cropper.vue +329 -0
- package/components/u-avatar-cropper/weCropper.d.ts +54 -0
- package/components/u-avatar-cropper/weCropper.js +1267 -0
- package/components/u-avatar-cropper/weCropper.ts +1254 -0
- package/components/u-back-top/u-back-top.vue +156 -0
- package/components/u-badge/u-badge.vue +189 -0
- package/components/u-button/u-button.vue +562 -0
- package/components/u-calendar/u-calendar.vue +725 -0
- package/components/u-car-keyboard/u-car-keyboard.vue +236 -0
- package/components/u-card/u-card.vue +240 -0
- package/components/u-cell-group/u-cell-group.vue +56 -0
- package/components/u-cell-item/u-cell-item.vue +245 -0
- package/components/u-checkbox/u-checkbox.vue +310 -0
- package/components/u-checkbox-group/u-checkbox-group.vue +134 -0
- package/components/u-circle-progress/u-circle-progress.vue +210 -0
- package/components/u-col/u-col.vue +135 -0
- package/components/u-collapse/u-collapse.vue +82 -0
- package/components/u-collapse-item/u-collapse-item.vue +190 -0
- package/components/u-column-notice/u-column-notice.vue +264 -0
- package/components/u-count-down/u-count-down.vue +333 -0
- package/components/u-count-to/u-count-to.vue +297 -0
- package/components/u-divider/u-divider.vue +141 -0
- package/components/u-dropdown/u-dropdown.vue +311 -0
- package/components/u-dropdown-item/u-dropdown-item.vue +135 -0
- package/components/u-empty/u-empty.vue +111 -0
- package/components/u-field/u-field.vue +469 -0
- package/components/u-form/u-form.vue +162 -0
- package/components/u-form-item/u-form-item.vue +476 -0
- package/components/u-full-screen/u-full-screen.vue +80 -0
- package/components/u-gap/u-gap.vue +48 -0
- package/components/u-grid/u-grid.vue +101 -0
- package/components/u-grid-item/u-grid-item.vue +136 -0
- package/components/u-icon/u-icon.vue +389 -0
- package/components/u-image/types.ts +48 -0
- package/components/u-image/u-image.vue +218 -0
- package/components/u-index-anchor/u-index-anchor.vue +101 -0
- package/components/u-index-list/u-index-list.vue +376 -0
- package/components/u-input/u-input.vue +462 -0
- package/components/u-keyboard/u-keyboard.vue +188 -0
- package/components/u-lazy-load/u-lazy-load.vue +288 -0
- package/components/u-line/u-line.vue +71 -0
- package/components/u-line-progress/u-line-progress.vue +128 -0
- package/components/u-link/u-link.vue +87 -0
- package/components/u-loading/u-loading.vue +111 -0
- package/components/u-loadmore/u-loadmore.vue +205 -0
- package/components/u-mask/u-mask.vue +137 -0
- package/components/u-message-input/u-message-input.vue +315 -0
- package/components/u-modal/u-modal.vue +284 -0
- package/components/u-navbar/u-navbar.vue +314 -0
- package/components/u-no-network/image.ts +2 -0
- package/components/u-no-network/u-no-network.vue +311 -0
- package/components/u-notice-bar/u-notice-bar.vue +274 -0
- package/components/u-number-box/u-number-box.vue +344 -0
- package/components/u-number-keyboard/u-number-keyboard.vue +170 -0
- package/components/u-parse/libs/CssHandler.js +100 -0
- package/components/u-parse/libs/MpHtmlParser.js +580 -0
- package/components/u-parse/libs/config.js +80 -0
- package/components/u-parse/libs/handler.wxs +22 -0
- package/components/u-parse/libs/trees.vue +505 -0
- package/components/u-parse/u-parse.vue +645 -0
- package/components/u-picker/u-picker.vue +808 -0
- package/components/u-popup/u-popup.vue +404 -0
- package/components/u-radio/u-radio.vue +272 -0
- package/components/u-radio-group/u-radio-group.vue +116 -0
- package/components/u-rate/u-rate.vue +349 -0
- package/components/u-read-more/u-read-more.vue +199 -0
- package/components/u-row/u-row.vue +95 -0
- package/components/u-row-notice/u-row-notice.vue +273 -0
- package/components/u-search/u-search.vue +298 -0
- package/components/u-section/u-section.vue +175 -0
- package/components/u-select/u-select.vue +387 -0
- package/components/u-skeleton/u-skeleton.vue +230 -0
- package/components/u-slider/u-slider.vue +293 -0
- package/components/u-steps/u-steps.vue +200 -0
- package/components/u-sticky/u-sticky.vue +189 -0
- package/components/u-subsection/u-subsection.vue +388 -0
- package/components/u-swipe-action/u-swipe-action.vue +289 -0
- package/components/u-swiper/u-swiper.vue +305 -0
- package/components/u-switch/u-switch.vue +146 -0
- package/components/u-tabbar/u-tabbar.vue +347 -0
- package/components/u-table/u-table.vue +104 -0
- package/components/u-tabs/u-tabs.vue +322 -0
- package/components/u-tabs-swiper/u-tabs-swiper.vue +426 -0
- package/components/u-tag/u-tag.vue +270 -0
- package/components/u-td/u-td.vue +76 -0
- package/components/u-th/u-th.vue +70 -0
- package/components/u-time-line/u-time-line.vue +39 -0
- package/components/u-time-line-item/u-time-line-item.vue +88 -0
- package/components/u-toast/types.ts +4 -0
- package/components/u-toast/u-toast.vue +238 -0
- package/components/u-top-tips/u-top-tips.vue +118 -0
- package/components/u-tr/u-tr.vue +24 -0
- package/components/u-upload/u-upload.vue +600 -0
- package/components/u-verification-code/u-verification-code.vue +194 -0
- package/components/u-waterfall/u-waterfall.vue +186 -0
- package/iconfont.css +910 -0
- package/index.scss +23 -0
- package/index.ts +166 -0
- package/libs/config/config.ts +26 -0
- package/libs/config/zIndex.ts +37 -0
- package/libs/css/color.scss +155 -0
- package/libs/css/common.scss +176 -0
- package/libs/css/style.components.scss +7 -0
- package/libs/css/style.h5.scss +8 -0
- package/libs/css/style.mp.scss +72 -0
- package/libs/css/style.nvue.scss +3 -0
- package/libs/css/style.vue.scss +175 -0
- package/libs/function/$parent.ts +22 -0
- package/libs/function/addUnit.ts +13 -0
- package/libs/function/color.ts +37 -0
- package/libs/function/colorGradient.ts +123 -0
- package/libs/function/debounce.ts +28 -0
- package/libs/function/deepClone.ts +39 -0
- package/libs/function/deepMerge.ts +34 -0
- package/libs/function/getParent.ts +59 -0
- package/libs/function/getRect.ts +26 -0
- package/libs/function/guid.ts +42 -0
- package/libs/function/md5.ts +397 -0
- package/libs/function/parent.ts +21 -0
- package/libs/function/queryParams.ts +60 -0
- package/libs/function/random.ts +16 -0
- package/libs/function/randomArray.ts +11 -0
- package/libs/function/route.ts +118 -0
- package/libs/function/sys.ts +15 -0
- package/libs/function/test.ts +229 -0
- package/libs/function/throttle.ts +31 -0
- package/libs/function/timeFormat.ts +54 -0
- package/libs/function/timeFrom.ts +48 -0
- package/libs/function/toast.ts +14 -0
- package/libs/function/trim.ts +21 -0
- package/libs/function/type2icon.ts +36 -0
- package/libs/hooks/useEmitter.ts +77 -0
- package/libs/hooks/useParent.ts +29 -0
- package/libs/request/index.ts +237 -0
- package/libs/store/index.ts +88 -0
- package/libs/util/area.ts +1 -0
- package/libs/util/async-validator.js +1356 -0
- package/libs/util/city.ts +1 -0
- package/libs/util/emitter.ts +112 -0
- package/libs/util/mitt.ts +118 -0
- package/libs/util/parent.ts +20 -0
- package/libs/util/province.ts +1 -0
- package/package.json +98 -0
- package/readme.md +165 -0
- package/theme.scss +38 -0
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
class="u-count-num"
|
|
4
|
+
:style="{
|
|
5
|
+
fontSize: props.fontSize + 'rpx',
|
|
6
|
+
fontWeight: props.bold ? 'bold' : 'normal',
|
|
7
|
+
color: props.color
|
|
8
|
+
}"
|
|
9
|
+
>
|
|
10
|
+
{{ displayValue }}
|
|
11
|
+
</view>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script setup lang="ts">
|
|
15
|
+
import { ref, computed, watch, onMounted, onUnmounted } from 'vue';
|
|
16
|
+
|
|
17
|
+
defineOptions({ name: 'u-count-to' });
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* countTo 数字滚动
|
|
21
|
+
* @description 该组件一般用于需要滚动数字到某一个值的场景,目标要求是一个递增的值。
|
|
22
|
+
* @tutorial https://www.uviewui.com/components/countTo.html
|
|
23
|
+
* @property {String | Number} start-val 开始值
|
|
24
|
+
* @property {String | Number} end-val 结束值
|
|
25
|
+
* @property {String | Number} duration 滚动过程所需的时间,单位ms(默认2000)
|
|
26
|
+
* @property {Boolean} autoplay 是否自动开始滚动(默认true)
|
|
27
|
+
* @property {String | Number} decimals 要显示的小数位数,见官网说明(默认0)
|
|
28
|
+
* @property {Boolean} use-easing 滚动结束时,是否缓动结尾,见官网说明(默认true)
|
|
29
|
+
* @property {String} separator 千位分隔符,见官网说明
|
|
30
|
+
* @property {String} color 字体颜色(默认#303133)
|
|
31
|
+
* @property {String | Number} font-size 字体大小,单位rpx(默认50)
|
|
32
|
+
* @property {Boolean} bold 字体是否加粗(默认false)
|
|
33
|
+
* @event {Function} end 数值滚动到目标值时触发
|
|
34
|
+
* @example <u-count-to ref="uCountTo" :end-val="endVal" :autoplay="autoplay"></u-count-to>
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
const emit = defineEmits(['end']);
|
|
38
|
+
|
|
39
|
+
const props = defineProps({
|
|
40
|
+
/** 开始的数值,默认从0增长到某一个数 */
|
|
41
|
+
startVal: {
|
|
42
|
+
type: [Number, String],
|
|
43
|
+
default: 0
|
|
44
|
+
},
|
|
45
|
+
/** 要滚动的目标数值,必须 */
|
|
46
|
+
endVal: {
|
|
47
|
+
type: [Number, String],
|
|
48
|
+
default: 0,
|
|
49
|
+
required: true
|
|
50
|
+
},
|
|
51
|
+
/** 滚动到目标数值的动画持续时间,单位为毫秒(ms) */
|
|
52
|
+
duration: {
|
|
53
|
+
type: [Number, String],
|
|
54
|
+
default: 2000
|
|
55
|
+
},
|
|
56
|
+
/** 设置数值后是否自动开始滚动 */
|
|
57
|
+
autoplay: {
|
|
58
|
+
type: Boolean,
|
|
59
|
+
default: true
|
|
60
|
+
},
|
|
61
|
+
/** 要显示的小数位数 */
|
|
62
|
+
decimals: {
|
|
63
|
+
type: [Number, String],
|
|
64
|
+
default: 0
|
|
65
|
+
},
|
|
66
|
+
/** 是否在即将到达目标数值的时候,使用缓慢滚动的效果 */
|
|
67
|
+
useEasing: {
|
|
68
|
+
type: Boolean,
|
|
69
|
+
default: true
|
|
70
|
+
},
|
|
71
|
+
/** 十进制分割符号 */
|
|
72
|
+
decimal: {
|
|
73
|
+
type: [Number, String],
|
|
74
|
+
default: '.'
|
|
75
|
+
},
|
|
76
|
+
/** 字体颜色 */
|
|
77
|
+
color: {
|
|
78
|
+
type: String,
|
|
79
|
+
default: '#303133'
|
|
80
|
+
},
|
|
81
|
+
/** 字体大小 */
|
|
82
|
+
fontSize: {
|
|
83
|
+
type: [Number, String],
|
|
84
|
+
default: 50
|
|
85
|
+
},
|
|
86
|
+
/** 是否加粗字体 */
|
|
87
|
+
bold: {
|
|
88
|
+
type: Boolean,
|
|
89
|
+
default: false
|
|
90
|
+
},
|
|
91
|
+
/** 千位分隔符,类似金额的分割(¥23,321.05中的",") */
|
|
92
|
+
separator: {
|
|
93
|
+
type: String,
|
|
94
|
+
default: ''
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const localStartVal = ref(Number(props.startVal));
|
|
99
|
+
const displayValue = ref(formatNumber(props.startVal));
|
|
100
|
+
const printVal = ref<number | null>(null);
|
|
101
|
+
const paused = ref(false); // 是否暂停
|
|
102
|
+
const localDuration = ref(Number(props.duration));
|
|
103
|
+
const startTime = ref<number | null>(null); // 开始的时间
|
|
104
|
+
const timestamp = ref<number | null>(null); // 时间戳
|
|
105
|
+
const remaining = ref<number | null>(null); // 停留的时间
|
|
106
|
+
const rAF = ref<number | null>(null);
|
|
107
|
+
const lastTime = ref(0); // 上一次的时间
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* 是否倒计时
|
|
111
|
+
*/
|
|
112
|
+
const countDown = computed(() => Number(props.startVal) > Number(props.endVal));
|
|
113
|
+
|
|
114
|
+
watch(
|
|
115
|
+
() => props.startVal,
|
|
116
|
+
() => {
|
|
117
|
+
if (props.autoplay) start();
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
watch(
|
|
121
|
+
() => props.endVal,
|
|
122
|
+
() => {
|
|
123
|
+
if (props.autoplay) start();
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
onMounted(() => {
|
|
128
|
+
if (props.autoplay) start();
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* 缓动函数
|
|
133
|
+
*/
|
|
134
|
+
function easingFn(t: number, b: number, c: number, d: number): number {
|
|
135
|
+
return (c * (-Math.pow(2, (-10 * t) / d) + 1) * 1024) / 1023 + b;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* requestAnimationFrame polyfill
|
|
140
|
+
*/
|
|
141
|
+
function requestAnimationFrame(callback: (ts: number) => void): number {
|
|
142
|
+
const currTime = new Date().getTime();
|
|
143
|
+
// 为了使setTimteout的尽可能的接近每秒60帧的效果
|
|
144
|
+
const timeToCall = Math.max(0, 16 - (currTime - lastTime.value));
|
|
145
|
+
const id = setTimeout(() => {
|
|
146
|
+
callback(currTime + timeToCall);
|
|
147
|
+
}, timeToCall);
|
|
148
|
+
lastTime.value = currTime + timeToCall;
|
|
149
|
+
return id as unknown as number;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* 取消动画帧
|
|
154
|
+
*/
|
|
155
|
+
function cancelAnimationFrame(id: number | null) {
|
|
156
|
+
if (id) clearTimeout(id);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* 开始滚动数字
|
|
161
|
+
*/
|
|
162
|
+
function start() {
|
|
163
|
+
localStartVal.value = Number(props.startVal);
|
|
164
|
+
startTime.value = null;
|
|
165
|
+
localDuration.value = Number(props.duration);
|
|
166
|
+
paused.value = false;
|
|
167
|
+
rAF.value = requestAnimationFrame(count);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* 暂停/恢复滚动
|
|
172
|
+
* 暂定状态,重新再开始滚动;或者滚动状态下,暂停
|
|
173
|
+
*/
|
|
174
|
+
function reStart() {
|
|
175
|
+
if (paused.value) {
|
|
176
|
+
resume();
|
|
177
|
+
paused.value = false;
|
|
178
|
+
} else {
|
|
179
|
+
stop();
|
|
180
|
+
paused.value = true;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* 暂停
|
|
186
|
+
*/
|
|
187
|
+
function stop() {
|
|
188
|
+
cancelAnimationFrame(rAF.value);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* 重新开始(暂停的情况下)
|
|
193
|
+
*/
|
|
194
|
+
function resume() {
|
|
195
|
+
startTime.value = null;
|
|
196
|
+
localDuration.value = remaining.value || Number(props.duration);
|
|
197
|
+
localStartVal.value = printVal.value || Number(props.startVal);
|
|
198
|
+
rAF.value = requestAnimationFrame(count);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* 重置
|
|
203
|
+
*/
|
|
204
|
+
function reset() {
|
|
205
|
+
startTime.value = null;
|
|
206
|
+
cancelAnimationFrame(rAF.value);
|
|
207
|
+
displayValue.value = formatNumber(props.startVal);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* 数字滚动动画主逻辑
|
|
212
|
+
*/
|
|
213
|
+
function count(ts: number) {
|
|
214
|
+
if (!startTime.value) startTime.value = ts;
|
|
215
|
+
timestamp.value = ts;
|
|
216
|
+
const progress = ts - (startTime.value || 0);
|
|
217
|
+
remaining.value = localDuration.value - progress;
|
|
218
|
+
let val: number;
|
|
219
|
+
if (props.useEasing) {
|
|
220
|
+
if (countDown.value) {
|
|
221
|
+
val = localStartVal.value - easingFn(progress, 0, localStartVal.value - Number(props.endVal), localDuration.value);
|
|
222
|
+
} else {
|
|
223
|
+
val = easingFn(progress, localStartVal.value, Number(props.endVal) - localStartVal.value, localDuration.value);
|
|
224
|
+
}
|
|
225
|
+
} else {
|
|
226
|
+
if (countDown.value) {
|
|
227
|
+
val = localStartVal.value - (localStartVal.value - Number(props.endVal)) * (progress / localDuration.value);
|
|
228
|
+
} else {
|
|
229
|
+
val = localStartVal.value + (Number(props.endVal) - localStartVal.value) * (progress / localDuration.value);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if (countDown.value) {
|
|
233
|
+
val = val < Number(props.endVal) ? Number(props.endVal) : val;
|
|
234
|
+
} else {
|
|
235
|
+
val = val > Number(props.endVal) ? Number(props.endVal) : val;
|
|
236
|
+
}
|
|
237
|
+
printVal.value = val;
|
|
238
|
+
displayValue.value = formatNumber(val);
|
|
239
|
+
if (progress < localDuration.value) {
|
|
240
|
+
rAF.value = requestAnimationFrame(count);
|
|
241
|
+
} else {
|
|
242
|
+
emit('end');
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* 判断是否数字
|
|
248
|
+
*/
|
|
249
|
+
function isNumber(val: unknown): boolean {
|
|
250
|
+
return !isNaN(parseFloat(String(val)));
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* 格式化数字
|
|
255
|
+
*/
|
|
256
|
+
function formatNumber(num: unknown): string {
|
|
257
|
+
// 将num转为Number类型,因为其值可能为字符串数值,调用toFixed会报错
|
|
258
|
+
let n = Number(num);
|
|
259
|
+
n = Number(n.toFixed(Number(props.decimals)));
|
|
260
|
+
let str = n + '';
|
|
261
|
+
const x = str.split('.');
|
|
262
|
+
let x1 = x[0];
|
|
263
|
+
const x2 = x.length > 1 ? String(props.decimal) + x[1] : '';
|
|
264
|
+
const rgx = /(\d+)(\d{3})/;
|
|
265
|
+
if (props.separator && !isNumber(props.separator)) {
|
|
266
|
+
while (rgx.test(x1)) {
|
|
267
|
+
x1 = x1.replace(rgx, '$1' + props.separator + '$2');
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return x1 + x2;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// 销毁时清理动画帧
|
|
274
|
+
onUnmounted(() => {
|
|
275
|
+
cancelAnimationFrame(rAF.value);
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
// 暴露给父组件的函数
|
|
279
|
+
defineExpose({
|
|
280
|
+
start,
|
|
281
|
+
stop,
|
|
282
|
+
reStart,
|
|
283
|
+
resume,
|
|
284
|
+
reset
|
|
285
|
+
});
|
|
286
|
+
</script>
|
|
287
|
+
|
|
288
|
+
<style lang="scss" scoped>
|
|
289
|
+
@import '../../libs/css/style.components.scss';
|
|
290
|
+
|
|
291
|
+
.u-count-num {
|
|
292
|
+
/* #ifndef APP-NVUE */
|
|
293
|
+
display: inline-flex;
|
|
294
|
+
/* #endif */
|
|
295
|
+
text-align: center;
|
|
296
|
+
}
|
|
297
|
+
</style>
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
class="u-divider"
|
|
4
|
+
:style="{
|
|
5
|
+
height: height === 'auto' ? 'auto' : height + 'rpx',
|
|
6
|
+
backgroundColor: bgColor,
|
|
7
|
+
marginBottom: marginBottom + 'rpx',
|
|
8
|
+
marginTop: marginTop + 'rpx'
|
|
9
|
+
}"
|
|
10
|
+
@tap="onClick"
|
|
11
|
+
>
|
|
12
|
+
<view class="u-divider-line" :class="[type ? 'u-divider-line--bordercolor--' + type : '']" :style="lineStyle"></view>
|
|
13
|
+
<view
|
|
14
|
+
v-if="useSlot"
|
|
15
|
+
class="u-divider-text"
|
|
16
|
+
:style="{
|
|
17
|
+
color: color,
|
|
18
|
+
fontSize: fontSize + 'rpx'
|
|
19
|
+
}"
|
|
20
|
+
><slot
|
|
21
|
+
/></view>
|
|
22
|
+
<view class="u-divider-line" :class="[type ? 'u-divider-line--bordercolor--' + type : '']" :style="lineStyle"></view>
|
|
23
|
+
</view>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<script setup lang="ts">
|
|
27
|
+
import { computed } from 'vue';
|
|
28
|
+
|
|
29
|
+
defineOptions({
|
|
30
|
+
name: 'u-divider'
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* divider 分割线
|
|
35
|
+
* @description 区隔内容的分割线,一般用于页面底部"没有更多"的提示。
|
|
36
|
+
* @tutorial https://www.uviewui.com/components/divider.html
|
|
37
|
+
* @property {String Number} half-width 文字左或右边线条宽度,数值或百分比,数值时单位为rpx
|
|
38
|
+
* @property {String} border-color 线条颜色,优先级高于type(默认#dcdfe6)
|
|
39
|
+
* @property {String} color 文字颜色(默认#909399)
|
|
40
|
+
* @property {String Number} fontSize 字体大小,单位rpx(默认26)
|
|
41
|
+
* @property {String} bg-color 整个divider的背景颜色(默认呢#ffffff)
|
|
42
|
+
* @property {String Number} height 整个divider的高度,单位rpx(默认40)
|
|
43
|
+
* @property {String} type 将线条设置主题色(默认primary)
|
|
44
|
+
* @property {Boolean} useSlot 是否使用slot传入内容,如果不传入,中间不会有空隙(默认true)
|
|
45
|
+
* @property {String Number} margin-top 与前一个组件的距离,单位rpx(默认0)
|
|
46
|
+
* @property {String Number} margin-bottom 与后一个组件的距离,单位rpx(0)
|
|
47
|
+
* @event {Function} click divider组件被点击时触发
|
|
48
|
+
* @example <u-divider color="#fa3534">长河落日圆</u-divider>
|
|
49
|
+
*/
|
|
50
|
+
const props = defineProps({
|
|
51
|
+
/** 单一边divider横线的宽度(数值),单位rpx。或者百分比 */
|
|
52
|
+
halfWidth: { type: [Number, String], default: 150 },
|
|
53
|
+
/** divider横线的颜色,如设置 */
|
|
54
|
+
borderColor: { type: String, default: '#dcdfe6' },
|
|
55
|
+
/** 主题色,可以是primary|info|success|warning|error之一值 */
|
|
56
|
+
type: { type: String, default: 'primary' },
|
|
57
|
+
/** 文字颜色 */
|
|
58
|
+
color: { type: String, default: '#909399' },
|
|
59
|
+
/** 文字大小,单位rpx */
|
|
60
|
+
fontSize: { type: [Number, String], default: 26 },
|
|
61
|
+
/** 整个divider的背景颜色 */
|
|
62
|
+
bgColor: { type: String, default: '#ffffff' },
|
|
63
|
+
/** 整个divider的高度单位rpx */
|
|
64
|
+
height: { type: [Number, String], default: 'auto' },
|
|
65
|
+
/** 上边距 */
|
|
66
|
+
marginTop: { type: [String, Number], default: 0 },
|
|
67
|
+
/** 下边距 */
|
|
68
|
+
marginBottom: { type: [String, Number], default: 0 },
|
|
69
|
+
/** 是否使用slot传入内容,如果不用slot传入内容,先的中间就不会有空隙 */
|
|
70
|
+
useSlot: { type: Boolean, default: true }
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const emit = defineEmits(['click']);
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* divider横线样式
|
|
77
|
+
*/
|
|
78
|
+
const lineStyle = computed(() => {
|
|
79
|
+
let style: Record<string, string> = {};
|
|
80
|
+
if (String(props.halfWidth).indexOf('%') !== -1) style.width = String(props.halfWidth);
|
|
81
|
+
else style.width = props.halfWidth + 'rpx';
|
|
82
|
+
// borderColor优先级高于type值
|
|
83
|
+
if (props.borderColor) style.borderColor = props.borderColor;
|
|
84
|
+
return style;
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* divider组件被点击时触发
|
|
89
|
+
*/
|
|
90
|
+
function onClick() {
|
|
91
|
+
emit('click');
|
|
92
|
+
}
|
|
93
|
+
</script>
|
|
94
|
+
|
|
95
|
+
<style lang="scss" scoped>
|
|
96
|
+
@import '../../libs/css/style.components.scss';
|
|
97
|
+
.u-divider {
|
|
98
|
+
width: 100%;
|
|
99
|
+
position: relative;
|
|
100
|
+
text-align: center;
|
|
101
|
+
@include vue-flex;
|
|
102
|
+
justify-content: center;
|
|
103
|
+
align-items: center;
|
|
104
|
+
overflow: hidden;
|
|
105
|
+
flex-direction: row;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.u-divider-line {
|
|
109
|
+
border-bottom: 1px solid $u-border-color;
|
|
110
|
+
transform: scale(1, 0.5);
|
|
111
|
+
transform-origin: center;
|
|
112
|
+
|
|
113
|
+
&--bordercolor--primary {
|
|
114
|
+
border-color: $u-type-primary;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
&--bordercolor--success {
|
|
118
|
+
border-color: $u-type-success;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
&--bordercolor--error {
|
|
122
|
+
border-color: $u-type-primary;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
&--bordercolor--info {
|
|
126
|
+
border-color: $u-type-info;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
&--bordercolor--warning {
|
|
130
|
+
border-color: $u-type-warning;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.u-divider-text {
|
|
135
|
+
white-space: nowrap;
|
|
136
|
+
padding: 0 16rpx;
|
|
137
|
+
/* #ifndef APP-NVUE */
|
|
138
|
+
display: inline-flex;
|
|
139
|
+
/* #endif */
|
|
140
|
+
}
|
|
141
|
+
</style>
|