stellar-ui-v2 1.35.3
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/common/css/common.scss +61 -0
- package/components/ste-animate/README.md +117 -0
- package/components/ste-animate/animate.scss +247 -0
- package/components/ste-animate/ste-animate.vue +200 -0
- package/components/ste-badge/README.md +171 -0
- package/components/ste-badge/ste-badge.vue +238 -0
- package/components/ste-barcode/README.md +36 -0
- package/components/ste-barcode/encode2.js +317 -0
- package/components/ste-barcode/ste-barcode.vue +213 -0
- package/components/ste-button/README.md +129 -0
- package/components/ste-button/ste-button.vue +345 -0
- package/components/ste-calendar/README.md +304 -0
- package/components/ste-calendar/self-date.js +119 -0
- package/components/ste-calendar/ste-calendar.vue +578 -0
- package/components/ste-checkbox/README.md +297 -0
- package/components/ste-checkbox/ste-checkbox.vue +305 -0
- package/components/ste-checkbox-group/ste-checkbox-group.vue +133 -0
- package/components/ste-code-input/README.md +67 -0
- package/components/ste-code-input/ste-code-input.vue +302 -0
- package/components/ste-date-picker/README.md +135 -0
- package/components/ste-date-picker/ste-date-picker.vue +407 -0
- package/components/ste-drag/README.md +103 -0
- package/components/ste-drag/ste-drag.vue +203 -0
- package/components/ste-dropdown-menu/README.md +358 -0
- package/components/ste-dropdown-menu/ste-dropdown-menu.vue +405 -0
- package/components/ste-dropdown-menu-item/ste-dropdown-menu-item.vue +176 -0
- package/components/ste-icon/README.md +90 -0
- package/components/ste-icon/iconfont.css +8 -0
- package/components/ste-icon/ste-icon.vue +147 -0
- package/components/ste-image/README.md +154 -0
- package/components/ste-image/ste-image.vue +218 -0
- package/components/ste-index-item/ste-index-item.vue +96 -0
- package/components/ste-index-list/README.md +153 -0
- package/components/ste-index-list/ste-index-list.vue +128 -0
- package/components/ste-input/README.md +146 -0
- package/components/ste-input/ste-input.vue +480 -0
- package/components/ste-loading/README.md +81 -0
- package/components/ste-loading/ste-loading.vue +166 -0
- package/components/ste-media-preview/README.md +243 -0
- package/components/ste-media-preview/TouchScaleing.js +102 -0
- package/components/ste-media-preview/ste-media-preview.vue +267 -0
- package/components/ste-message-box/README.md +217 -0
- package/components/ste-message-box/ste-message-box.js +72 -0
- package/components/ste-message-box/ste-message-box.vue +380 -0
- package/components/ste-notice-bar/README.md +129 -0
- package/components/ste-notice-bar/ste-notice-bar.vue +331 -0
- package/components/ste-number-keyboard/README.md +246 -0
- package/components/ste-number-keyboard/keyboard.vue +140 -0
- package/components/ste-number-keyboard/ste-number-keyboard.vue +240 -0
- package/components/ste-picker/ste-picker.vue +258 -0
- package/components/ste-popup/README.md +148 -0
- package/components/ste-popup/ste-popup.vue +337 -0
- package/components/ste-price/README.md +129 -0
- package/components/ste-price/ste-price.vue +258 -0
- package/components/ste-progress/README.md +87 -0
- package/components/ste-progress/ste-progress.vue +200 -0
- package/components/ste-qrcode/README.md +50 -0
- package/components/ste-qrcode/ste-qrcode.vue +164 -0
- package/components/ste-qrcode/uqrcode.js +34 -0
- package/components/ste-radio/README.md +286 -0
- package/components/ste-radio/ste-radio.vue +293 -0
- package/components/ste-radio-group/ste-radio-group.vue +128 -0
- package/components/ste-rate/README.md +115 -0
- package/components/ste-rate/ste-rate.vue +202 -0
- package/components/ste-read-more/README.md +111 -0
- package/components/ste-read-more/ste-read-more.vue +133 -0
- package/components/ste-rich-text/README.md +31 -0
- package/components/ste-rich-text/ste-rich-text.vue +70 -0
- package/components/ste-scroll-to/README.md +68 -0
- package/components/ste-scroll-to/mixin.js +173 -0
- package/components/ste-scroll-to/ste-scroll-to.vue +45 -0
- package/components/ste-scroll-to-item/ste-scroll-to-item.vue +25 -0
- package/components/ste-search/README.md +262 -0
- package/components/ste-search/ste-search.vue +547 -0
- package/components/ste-select/README.md +434 -0
- package/components/ste-select/datapager.vue +62 -0
- package/components/ste-select/datetime.vue +106 -0
- package/components/ste-select/defaultDate.js +142 -0
- package/components/ste-select/ste-select.vue +843 -0
- package/components/ste-signature/README.md +105 -0
- package/components/ste-signature/ste-signature.vue +220 -0
- package/components/ste-slider/README.md +165 -0
- package/components/ste-slider/ste-slider.vue +544 -0
- package/components/ste-step/ste-step.vue +264 -0
- package/components/ste-stepper/README.md +170 -0
- package/components/ste-stepper/ste-stepper.vue +373 -0
- package/components/ste-steps/README.md +132 -0
- package/components/ste-steps/ste-steps.vue +65 -0
- package/components/ste-sticky/README.md +52 -0
- package/components/ste-sticky/ste-sticky.vue +127 -0
- package/components/ste-swipe-action/README.md +197 -0
- package/components/ste-swipe-action/ste-swipe-action.vue +303 -0
- package/components/ste-swipe-action-group/ste-swipe-action-group.vue +104 -0
- package/components/ste-swiper/README.md +173 -0
- package/components/ste-swiper/ste-swiper.vue +462 -0
- package/components/ste-swiper-item/ste-swiper-item.vue +41 -0
- package/components/ste-switch/README.md +110 -0
- package/components/ste-switch/ste-switch.vue +144 -0
- package/components/ste-tab/ste-tab.vue +87 -0
- package/components/ste-table/README.md +785 -0
- package/components/ste-table/common.js +8 -0
- package/components/ste-table/ste-table.vue +666 -0
- package/components/ste-table/utils.js +20 -0
- package/components/ste-table-column/checkbox-icon.vue +65 -0
- package/components/ste-table-column/common.scss +65 -0
- package/components/ste-table-column/radio-icon.vue +110 -0
- package/components/ste-table-column/ste-table-column.vue +255 -0
- package/components/ste-table-column/sub-table.vue +116 -0
- package/components/ste-table-column/table-popover.vue +204 -0
- package/components/ste-table-column/var.scss +1 -0
- package/components/ste-tabs/README.md +475 -0
- package/components/ste-tabs/props.js +212 -0
- package/components/ste-tabs/ste-tabs.vue +758 -0
- package/components/ste-text/README.md +66 -0
- package/components/ste-text/ste-text.vue +72 -0
- package/components/ste-toast/README.md +243 -0
- package/components/ste-toast/ste-toast.js +69 -0
- package/components/ste-toast/ste-toast.vue +231 -0
- package/components/ste-touch-swipe/README.md +104 -0
- package/components/ste-touch-swipe/TouchEvent.js +72 -0
- package/components/ste-touch-swipe/ste-touch-swipe.vue +327 -0
- package/components/ste-touch-swipe-item/ste-touch-swipe-item.vue +33 -0
- package/components/ste-tour/README.md +194 -0
- package/components/ste-tour/ste-tour.vue +355 -0
- package/components/ste-tree/README.md +240 -0
- package/components/ste-tree/ste-tree.vue +350 -0
- package/components/ste-upload/README.md +276 -0
- package/components/ste-upload/ReadFile.js +229 -0
- package/components/ste-upload/ste-upload.vue +526 -0
- package/components/ste-video/README.md +60 -0
- package/components/ste-video/props.js +149 -0
- package/components/ste-video/ste-video.vue +647 -0
- package/config/color.js +22 -0
- package/index.js +2 -0
- package/package.json +19 -0
- package/utils/Color.js +66 -0
- package/utils/System.js +110 -0
- package/utils/dayjs.min.js +1 -0
- package/utils/mixin.js +67 -0
- package/utils/store.js +7 -0
- package/utils/utils.js +604 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Signature 签名
|
|
2
|
+
|
|
3
|
+
签名组件用于在页面上显示签名。
|
|
4
|
+
|
|
5
|
+
---$
|
|
6
|
+
|
|
7
|
+
### 代码演示
|
|
8
|
+
#### 基础使用
|
|
9
|
+
- `type` 签名保存图片类型,支持 `jpg` 和 `png`(默认) 两种格式。
|
|
10
|
+
- 此处使用 `jpg` 格式。因为媒体预览背景是黑色,画笔颜色是黑色,`png`格式图片时预览看不见
|
|
11
|
+
```html
|
|
12
|
+
<template>
|
|
13
|
+
<view class="signature-box">
|
|
14
|
+
<ste-signature ref="signature" type="jpg" />
|
|
15
|
+
</view>
|
|
16
|
+
<ste-button @click="clear">清除</ste-button>
|
|
17
|
+
<ste-button @click="upstep">上一步</ste-button>
|
|
18
|
+
<ste-button @click="save">保存并预览</ste-button>
|
|
19
|
+
<ste-media-preview :show.sync="show" :urls="urls"></ste-media-preview>
|
|
20
|
+
</template>
|
|
21
|
+
<script>
|
|
22
|
+
export default {
|
|
23
|
+
data() {
|
|
24
|
+
return {
|
|
25
|
+
show: false,
|
|
26
|
+
urls: [],
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
methods: {
|
|
30
|
+
clear() {
|
|
31
|
+
this.$refs.signature.clear();
|
|
32
|
+
},
|
|
33
|
+
upstep() {
|
|
34
|
+
this.$refs.signature.back();
|
|
35
|
+
},
|
|
36
|
+
save() {
|
|
37
|
+
this.$refs.signature.save(
|
|
38
|
+
(base64) => {
|
|
39
|
+
this.urls = [base64];
|
|
40
|
+
this.show = true;
|
|
41
|
+
},
|
|
42
|
+
(err) => {
|
|
43
|
+
this.showToast({
|
|
44
|
+
title: err,
|
|
45
|
+
icon: 'none',
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
</script>
|
|
53
|
+
<style lang="scss" scoped>
|
|
54
|
+
.signature-box {
|
|
55
|
+
width: 100%;
|
|
56
|
+
height: 300rpx;
|
|
57
|
+
background-color: #f5f5f5;
|
|
58
|
+
margin-bottom: 30rpx;
|
|
59
|
+
}
|
|
60
|
+
</style>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
#### 背景、画笔颜色和线宽
|
|
64
|
+
- 属性`background`可以自定义图片背景颜色,默认`#f8f8f8`(黑色)
|
|
65
|
+
- 属性`strokeColor`可以自定义画笔颜色,默认`#000000`(黑色)
|
|
66
|
+
- 属性`lineWidth`可以自定义画笔线宽,默认`3`
|
|
67
|
+
```html
|
|
68
|
+
<ste-signature background="#0f0" strokeColor="#f0f" lineWidth="1" />
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
---$
|
|
73
|
+
### API
|
|
74
|
+
#### 组件属性(Props)
|
|
75
|
+
|
|
76
|
+
| 属性名 | 说明 | 类型 | 默认值 | 可选值 | 支持版本 |
|
|
77
|
+
| --- | --- | --- | --- | --- | --- |
|
|
78
|
+
| `customClass` | 自定义 class | `String` | - | - | - |
|
|
79
|
+
| `lineWidth` | 线条的宽度 | `Number` | `3` | - | - |
|
|
80
|
+
| `background` | 背景颜色 | `String` | `none` | - | - |
|
|
81
|
+
| `strokeColor` | 线条的颜色 | `String` | `#000000` | - | - |
|
|
82
|
+
| `type` | 保存图片类型 | `String` | `png` | `jpg` | - |
|
|
83
|
+
| `width` | 宽度,单位rpx | `String`,`Number` | `100%` | - | - |
|
|
84
|
+
| `height` | 高度,单位rpx | `String`,`Number` | `100%` | - | - |
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
#### 组件事件(Events)
|
|
88
|
+
|
|
89
|
+
|事件名 |说明 |事件参数 |支持版本 |
|
|
90
|
+
|--- |--- |--- |--- |
|
|
91
|
+
|`start` | 笔画开始 | - |- |
|
|
92
|
+
|`signing`| 正在书写中 | - |- |
|
|
93
|
+
|`end` | 笔画结束 |- |- |
|
|
94
|
+
|
|
95
|
+
#### 组件方法(Method)
|
|
96
|
+
|
|
97
|
+
|方法名 | 说明 |方法参数 |支持版本 |
|
|
98
|
+
|--- |--- |--- |--- |
|
|
99
|
+
|`clear`| 清空画布 |- |- |
|
|
100
|
+
|`back` | 回退 |- |- |
|
|
101
|
+
|`save` | 保存为图片 |(base64)=>void,(err)=>void |- |
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
---$
|
|
105
|
+
{{xuyajun}}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
v-if="load"
|
|
4
|
+
class="ste-signature-root"
|
|
5
|
+
:style="[cmpRootStyle]"
|
|
6
|
+
:class="customClass"
|
|
7
|
+
@mousedown="onTouchStart"
|
|
8
|
+
@mousemove="onTouchMove"
|
|
9
|
+
@mouseup="onTouchEnd"
|
|
10
|
+
@mosueleave="onTouchEnd"
|
|
11
|
+
>
|
|
12
|
+
<canvas
|
|
13
|
+
disable-scroll
|
|
14
|
+
:id="canvasId"
|
|
15
|
+
:canvas-id="canvasId"
|
|
16
|
+
:style="[cmpRootStyle]"
|
|
17
|
+
@touchstart="onTouchStart"
|
|
18
|
+
@touchmove="onTouchMove"
|
|
19
|
+
@touchend="onTouchEnd"
|
|
20
|
+
/>
|
|
21
|
+
</view>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script>
|
|
25
|
+
import utils from '../../utils/utils';
|
|
26
|
+
/**
|
|
27
|
+
* ste-signature 签名
|
|
28
|
+
* @description 签名组件
|
|
29
|
+
* @tutorial https://stellar-ui.intecloud.com.cn/pc/index/index?name=ste-signature
|
|
30
|
+
* @property {String} customClass 自定义 class
|
|
31
|
+
* @property {Number} lineWidth 线条的宽度
|
|
32
|
+
* @property {String} strokeColor 线条颜色,支持 rgb,rgba,hex,hsl,hsla,颜色名称等格式
|
|
33
|
+
* @property {String} background 图片背景色
|
|
34
|
+
* @property {String} type 保存图片类型
|
|
35
|
+
* @value png 默认
|
|
36
|
+
* @value jpg
|
|
37
|
+
* @property {String|Number} width 宽度,单位rpx
|
|
38
|
+
* @property {String|Number} height 高度,单位rpx
|
|
39
|
+
* @event {Function} start 开始签名事件
|
|
40
|
+
* @event {Function} signing 正在签名事件(指某次笔画进行中)
|
|
41
|
+
* @event {Function} end 结束签名事件
|
|
42
|
+
*/
|
|
43
|
+
export default {
|
|
44
|
+
group: '表单组件',
|
|
45
|
+
title: 'Signature 签名',
|
|
46
|
+
name: 'ste-signature',
|
|
47
|
+
props: {
|
|
48
|
+
customClass: {
|
|
49
|
+
type: [String, null],
|
|
50
|
+
default: () => '',
|
|
51
|
+
},
|
|
52
|
+
lineWidth: {
|
|
53
|
+
type: [Number, String, null],
|
|
54
|
+
default: () => 3,
|
|
55
|
+
},
|
|
56
|
+
strokeColor: {
|
|
57
|
+
type: [String, null],
|
|
58
|
+
default: () => 'black',
|
|
59
|
+
},
|
|
60
|
+
background: {
|
|
61
|
+
type: [String, null],
|
|
62
|
+
default: () => 'none',
|
|
63
|
+
},
|
|
64
|
+
type: {
|
|
65
|
+
type: [String, null],
|
|
66
|
+
default: () => 'png',
|
|
67
|
+
},
|
|
68
|
+
width: {
|
|
69
|
+
type: [Number, String, null],
|
|
70
|
+
default: () => '100%',
|
|
71
|
+
},
|
|
72
|
+
height: {
|
|
73
|
+
type: [Number, String, null],
|
|
74
|
+
default: () => '100%',
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
data() {
|
|
78
|
+
return {
|
|
79
|
+
canvasId: utils.guid(8),
|
|
80
|
+
load: false,
|
|
81
|
+
ctx: null,
|
|
82
|
+
strokes: [],
|
|
83
|
+
strokeing: [],
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
computed: {
|
|
87
|
+
cmpRootStyle() {
|
|
88
|
+
return {
|
|
89
|
+
width: utils.formatPx(this.width),
|
|
90
|
+
height: utils.formatPx(this.height),
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
mounted() {
|
|
95
|
+
this.load = true;
|
|
96
|
+
this.$nextTick(() => {
|
|
97
|
+
this.initCanvas();
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
methods: {
|
|
101
|
+
clear() {
|
|
102
|
+
this.strokes = [];
|
|
103
|
+
this.drawStrokes();
|
|
104
|
+
},
|
|
105
|
+
back() {
|
|
106
|
+
this.strokes.pop();
|
|
107
|
+
this.drawStrokes();
|
|
108
|
+
},
|
|
109
|
+
async save(callback, error) {
|
|
110
|
+
if (!this.strokes.length) {
|
|
111
|
+
if (error) error('请绘制签名');
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const canvas = await utils.querySelector(`.ste-signature-root`, this);
|
|
115
|
+
uni.canvasToTempFilePath(
|
|
116
|
+
{
|
|
117
|
+
canvasId: this.canvasId,
|
|
118
|
+
width: canvas.width,
|
|
119
|
+
height: canvas.height,
|
|
120
|
+
destWidth: canvas.width * 2, // 设置导出图片的宽度,这里设置为canvas宽度的两倍
|
|
121
|
+
destHeight: canvas.height * 2, // 设置导出图片的高度,这里设置为canvas高度的两倍
|
|
122
|
+
fileType: this.type, // 设置导出图片的类型,如'png'、'jpg'等
|
|
123
|
+
success: (res) => {
|
|
124
|
+
if (callback) callback(res.tempFilePath);
|
|
125
|
+
},
|
|
126
|
+
fail: (err) => {
|
|
127
|
+
console.error(err, 'err');
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
this
|
|
131
|
+
);
|
|
132
|
+
},
|
|
133
|
+
async initCanvas() {
|
|
134
|
+
this.ctx = uni.createCanvasContext(this.canvasId, this);
|
|
135
|
+
this.drawStrokes();
|
|
136
|
+
},
|
|
137
|
+
drawStrokes(ctx = this.ctx) {
|
|
138
|
+
// 设置线条圆角
|
|
139
|
+
this.ctx.setLineCap('round');
|
|
140
|
+
this.ctx.setStrokeStyle(this.strokeColor); // 设置线颜色为黑色
|
|
141
|
+
this.ctx.setLineWidth(this.lineWidth); // 设置线宽
|
|
142
|
+
ctx.clearRect(0, 0, 1920, 1080);
|
|
143
|
+
if (this.background !== 'none') {
|
|
144
|
+
ctx.setFillStyle(this.background);
|
|
145
|
+
ctx.fillRect(0, 0, 1920, 1080);
|
|
146
|
+
}
|
|
147
|
+
ctx.draw();
|
|
148
|
+
if (!this.strokes?.length) {
|
|
149
|
+
ctx.stroke();
|
|
150
|
+
ctx.draw(true);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
this.strokes.forEach((stroke) => {
|
|
155
|
+
if (!stroke.length) return;
|
|
156
|
+
ctx.beginPath();
|
|
157
|
+
ctx.moveTo(stroke[0].x, stroke[0].y);
|
|
158
|
+
stroke.forEach(({ x, y }, index) => {
|
|
159
|
+
if (index == 0) return;
|
|
160
|
+
ctx.lineTo(x, y);
|
|
161
|
+
});
|
|
162
|
+
ctx.stroke();
|
|
163
|
+
ctx.draw(true);
|
|
164
|
+
});
|
|
165
|
+
},
|
|
166
|
+
drawStrokeing(ctx = this.ctx) {
|
|
167
|
+
const length = this.strokeing?.length;
|
|
168
|
+
if (!length) return;
|
|
169
|
+
ctx.beginPath();
|
|
170
|
+
const end = this.strokeing[length - 1];
|
|
171
|
+
const start = this.strokeing[length - 2] || end;
|
|
172
|
+
ctx.moveTo(start.x, start.y);
|
|
173
|
+
ctx.lineTo(end.x, end.y);
|
|
174
|
+
ctx.stroke();
|
|
175
|
+
ctx.draw(true);
|
|
176
|
+
},
|
|
177
|
+
async onTouchStart(e) {
|
|
178
|
+
// #ifdef MP
|
|
179
|
+
this.strokeing = [{ x: e.changedTouches[0].x, y: e.changedTouches[0].y }];
|
|
180
|
+
// #endif
|
|
181
|
+
// #ifdef H5
|
|
182
|
+
this.strokeing = [await this.getH5MousePosition(e)];
|
|
183
|
+
// #endif
|
|
184
|
+
this.drawStrokeing();
|
|
185
|
+
this.$emit('start');
|
|
186
|
+
},
|
|
187
|
+
async onTouchMove(e) {
|
|
188
|
+
if (!this.strokeing?.length) return;
|
|
189
|
+
// #ifdef MP
|
|
190
|
+
this.strokeing.push({ x: e.changedTouches[0].x, y: e.changedTouches[0].y });
|
|
191
|
+
// #endif
|
|
192
|
+
// #ifdef H5
|
|
193
|
+
this.strokeing.push(await this.getH5MousePosition(e));
|
|
194
|
+
// #endif
|
|
195
|
+
this.drawStrokeing();
|
|
196
|
+
this.$emit('signing');
|
|
197
|
+
},
|
|
198
|
+
onTouchEnd(e) {
|
|
199
|
+
this.strokes.push(this.strokeing);
|
|
200
|
+
this.strokeing = [];
|
|
201
|
+
this.$emit('end');
|
|
202
|
+
},
|
|
203
|
+
|
|
204
|
+
// #ifdef H5
|
|
205
|
+
async getH5MousePosition(e) {
|
|
206
|
+
const canvas = await utils.querySelector(`#${this.canvasId}`, this);
|
|
207
|
+
return {
|
|
208
|
+
x: e.clientX - canvas.left,
|
|
209
|
+
y: e.clientY - canvas.top,
|
|
210
|
+
};
|
|
211
|
+
},
|
|
212
|
+
// #endif
|
|
213
|
+
},
|
|
214
|
+
};
|
|
215
|
+
</script>
|
|
216
|
+
|
|
217
|
+
<style scoped lang="scss">
|
|
218
|
+
.ste-signature-root {
|
|
219
|
+
}
|
|
220
|
+
</style>
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# Slider 滑块
|
|
2
|
+
|
|
3
|
+
用于选择横轴或者竖轴上的数值、区间、档位。
|
|
4
|
+
|
|
5
|
+
---$
|
|
6
|
+
|
|
7
|
+
### 代码演示
|
|
8
|
+
#### 基础使用
|
|
9
|
+
```html
|
|
10
|
+
<ste-slider value="30"></ste-slider>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
#### 滑块条高度 & 滑块大小
|
|
14
|
+
```html
|
|
15
|
+
<ste-slider barHeight="26" value="30"></ste-slider>
|
|
16
|
+
<ste-slider buttonSize="50" value="30"></ste-slider>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
#### 进度条颜色
|
|
20
|
+
```html
|
|
21
|
+
<ste-slider value="30" activeColor="#ff0000" inactiveColor="#a9ee13"></ste-slider>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
#### 范围选择
|
|
25
|
+
```html
|
|
26
|
+
<ste-slider :value="[10, 20]" range></ste-slider>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
#### 竖向
|
|
30
|
+
```html
|
|
31
|
+
<ste-slider vertical value="30"></ste-slider>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
#### 禁用
|
|
35
|
+
```html
|
|
36
|
+
<ste-slider disabled value="30"></ste-slider>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
#### 只读
|
|
40
|
+
```html
|
|
41
|
+
<ste-slider readonly value="30"></ste-slider>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
#### 间断点
|
|
45
|
+
当`showStops`为`true`时,会根据最大值(`max`)、最小值(`min`)、步长(`step`)来显示间断点
|
|
46
|
+
```html
|
|
47
|
+
<ste-slider showStops :step="10" value="30"></ste-slider>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
#### 标记
|
|
51
|
+
当同时配置了`showStops`属性和`marks`属性时,会显示自定义节点
|
|
52
|
+
```html
|
|
53
|
+
<ste-slider showStops :marks="marks" value="30"></ste-slider>
|
|
54
|
+
<script>
|
|
55
|
+
export default {
|
|
56
|
+
data() {
|
|
57
|
+
return {
|
|
58
|
+
marks: {
|
|
59
|
+
10: '0°C',
|
|
60
|
+
20: '8°C',
|
|
61
|
+
37: '37°C',
|
|
62
|
+
80: {
|
|
63
|
+
style: {
|
|
64
|
+
color: '#1989FA',
|
|
65
|
+
},
|
|
66
|
+
label: '合格',
|
|
67
|
+
},
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
</script>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
#### 自定义滑块
|
|
76
|
+
```html
|
|
77
|
+
<ste-slider :step="10" showStops value="30" activeColor="#ff0000">
|
|
78
|
+
<view class="c-slider-1" slot="button">
|
|
79
|
+
<view class="content">
|
|
80
|
+
<text>滑块</text>
|
|
81
|
+
</view>
|
|
82
|
+
</view>
|
|
83
|
+
</ste-slider>
|
|
84
|
+
<ste-slider :step="10" showStops :value="[10, 40]" range>
|
|
85
|
+
<view class="c-slider-2" slot="leftButton">
|
|
86
|
+
<view class="content">
|
|
87
|
+
<ste-icon code="" color="#fff"></ste-icon>
|
|
88
|
+
</view>
|
|
89
|
+
</view>
|
|
90
|
+
<view class="c-slider-2" slot="rightButton">
|
|
91
|
+
<view class="content">
|
|
92
|
+
<ste-icon code="" color="#fff"></ste-icon>
|
|
93
|
+
</view>
|
|
94
|
+
</view>
|
|
95
|
+
</ste-slider>
|
|
96
|
+
<style lang="scss">
|
|
97
|
+
.c-slider-1 {
|
|
98
|
+
.content {
|
|
99
|
+
padding: 0 16rpx;
|
|
100
|
+
background-color: #ff0000;
|
|
101
|
+
border-radius: 20rpx;
|
|
102
|
+
|
|
103
|
+
color: #ffffff;
|
|
104
|
+
font-size: 24rpx;
|
|
105
|
+
|
|
106
|
+
text {
|
|
107
|
+
white-space: nowrap;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
.c-slider-2 {
|
|
112
|
+
.content {
|
|
113
|
+
background-color: #0090FF;
|
|
114
|
+
border-radius: 50%;
|
|
115
|
+
height: 40rpx;
|
|
116
|
+
width: 40rpx;
|
|
117
|
+
display: flex;
|
|
118
|
+
align-items: center;
|
|
119
|
+
justify-content: center;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
</style>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
---$
|
|
126
|
+
### API
|
|
127
|
+
#### 组件属性(Props)
|
|
128
|
+
|
|
129
|
+
| 属性名 | 说明 | 类型 | 默认值 | 可选值 | 支持版本 |
|
|
130
|
+
| --- | --- | --- | --- | --- | --- |
|
|
131
|
+
| `value` | 当前进度百分比,在双滑块模式下为数组格式(数组的值都是从小到大) | `Number/String/Array` | `0` | - | - |
|
|
132
|
+
| `min` | 最小值 | `Number/String/Array` | `0` | - | - |
|
|
133
|
+
| `max` | 最大值 | `Number/String/Array` | `100` | - | - |
|
|
134
|
+
| `step` | 步长 | `Number/String/Array` | `1` | - | - |
|
|
135
|
+
| `barHeight` | 进度条高度,默认单位为 rpx | `Number/String/Array` | `8` | - | - |
|
|
136
|
+
| `buttonSize` | 滑块按钮大小,默认单位为 rpx | `Number/String/Array` | `40` | - | - |
|
|
137
|
+
| `activeColor` | 进度条激活态颜色 | `Number/String/Array` | `#0090FF` | - | - |
|
|
138
|
+
| `inactiveColor` | 进度条非激活态颜色 | `Number/String/Array` | `#eeeeee` | - | - |
|
|
139
|
+
| `range` | 是否为范围选择 | `Number/String/Array` | `false` | - | - |
|
|
140
|
+
| `vertical` | 是否竖向模式 | `Number/String/Array` | `false` | - | - |
|
|
141
|
+
| `disabled` | 是否禁用滑块 | `Number/String/Array` | `false` | - | - |
|
|
142
|
+
| `readonly` | 是否为只读状态,只读状态下无法修改滑块的值 | `Number/String/Array` | `false` | - | - |
|
|
143
|
+
| `showStops` | 是否显示间断点 | `Number/String/Array` | `false` | - | - |
|
|
144
|
+
| `marks` | 标记, key 的类型必须为 number 且取值在闭区间 [min, max] 内,每个标记可以单独设置样式 | `Number/String/Array` | `{}` | - | - |
|
|
145
|
+
|
|
146
|
+
#### 组件事件(Events)
|
|
147
|
+
|
|
148
|
+
|事件名 |说明 |事件参数 |支持版本 |
|
|
149
|
+
|--- |--- |--- |--- |
|
|
150
|
+
|`input` |进度变化时实时触发 |`value`:改变后的绑定值 |- |
|
|
151
|
+
|`change` |进度变化且结束拖动后触发 |`value`:改变后的绑定值 |- |
|
|
152
|
+
|`dragStart`|开始拖动时触发 |- |- |
|
|
153
|
+
|`dragEnd` |结束拖动时触发 |- |- |
|
|
154
|
+
|
|
155
|
+
#### 组件插槽(Slots)
|
|
156
|
+
|
|
157
|
+
|插槽名 |说明 |插槽参数 |支持版本 |
|
|
158
|
+
|--- |--- |--- |--- |
|
|
159
|
+
|`button` |自定义滑块按钮 |- |- |
|
|
160
|
+
|`button` |自定义左侧滑块按钮(范围选择下) |- |- |
|
|
161
|
+
|`button` |自定义右侧滑块按钮(范围选择下) |- |- |
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
---$
|
|
165
|
+
{{fuyuwei}}
|