kui-vue 3.2.3 → 3.2.4
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/LICENSE +0 -0
- package/components/affix/affix.jsx +23 -75
- package/components/affix/demo/container.md +14 -7
- package/components/affix/index.md +6 -5
- package/components/anchor/demo/base.md +11 -11
- package/components/anchor/demo/index.vue +16 -16
- package/components/anchor/demo/info.md +6 -6
- package/components/anchor/index.js +2 -2
- package/components/anchor/index.md +3 -3
- package/components/avatar/avatar.jsx +63 -0
- package/components/avatar/demo/base.md +24 -0
- package/components/avatar/demo/change.md +40 -0
- package/components/avatar/demo/index.vue +20 -0
- package/components/avatar/demo/info.md +7 -0
- package/components/avatar/demo/types.md +23 -0
- package/components/avatar/index.js +2 -0
- package/components/avatar/index.md +7 -0
- package/components/avatar/styles/index.less +61 -0
- package/components/checkbox/styles/index.less +5 -1
- package/components/drawer/demo/target.md +0 -0
- package/components/icon/lib/dist.json +0 -0
- package/components/icon/lib/kui-icons.js +0 -0
- package/components/index.js +7 -1
- package/components/loading/demo/index.vue +17 -17
- package/components/loading/demo/info.md +54 -54
- package/components/loading/index.md +7 -7
- package/components/radio/styles/index.less +4 -1
- package/components/rate/demo/base.md +11 -11
- package/components/rate/demo/index.vue +29 -29
- package/components/rate/demo/info.md +7 -7
- package/components/rate/index.js +1 -1
- package/components/rate/index.md +11 -11
- package/components/rate/rate.jsx +93 -93
- package/components/slider/demo/base.md +35 -0
- package/components/slider/demo/index.vue +18 -0
- package/components/slider/demo/info.md +7 -0
- package/components/slider/demo/vertical.md +13 -0
- package/components/slider/index.md +7 -0
- package/components/slider/slider.jsx +58 -0
- package/components/slider/styles/index.less +60 -32
- package/components/space/demo/align.md +46 -0
- package/components/space/demo/base.md +20 -0
- package/components/space/demo/custom-size.md +35 -0
- package/components/space/demo/index.vue +25 -0
- package/components/space/demo/info.md +11 -0
- package/components/space/demo/size.md +35 -0
- package/components/space/demo/vertical.md +19 -0
- package/components/space/index.js +2 -0
- package/components/space/index.md +6 -0
- package/components/space/space.jsx +57 -0
- package/components/space/styles/index.less +23 -0
- package/components/styles/dark.less +3 -0
- package/components/styles/global-dark.less +35 -35
- package/components/styles/index.less +3 -0
- package/components/table/demo/base-render.md +1 -1
- package/components/table/demo/base.md +5 -2
- package/components/table/table.jsx +10 -7
- package/dist/k-ui-dark.css +1 -1
- package/dist/k-ui.css +1 -1
- package/dist/k-ui.js +2 -2
- package/package.json +3 -2
- package/components/slider/demo/slider.js +0 -5
- package/components/slider/slider.vue +0 -21
- package/components/slider/sliderButton.vue +0 -76
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
# Loading 加载进度
|
|
2
|
-
进度加载。
|
|
3
|
-
|
|
4
|
-
## 何时使用
|
|
5
|
-
- 异步请求时展示进度
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
## 示例
|
|
9
|
-
|
|
10
|
-
模拟路由加载
|
|
11
|
-
```js
|
|
12
|
-
// # router.js
|
|
13
|
-
|
|
14
|
-
import Vue from 'vue'
|
|
15
|
-
import Router from 'vue-router'
|
|
16
|
-
import kui from 'kui-vue'
|
|
17
|
-
|
|
18
|
-
Vue.use(Router)
|
|
19
|
-
let router = new Router({
|
|
20
|
-
....
|
|
21
|
-
})
|
|
22
|
-
router.beforeEach((to, from, next) => {
|
|
23
|
-
kui.Loading.start();
|
|
24
|
-
next();
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
router.afterEach(route => {
|
|
28
|
-
kui.Loading.finish();
|
|
29
|
-
});
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
模拟ajax 请求
|
|
33
|
-
```js
|
|
34
|
-
// 以jQuery的Ajax为例,部分代码省略
|
|
35
|
-
import $ from 'jquery';
|
|
36
|
-
export default {
|
|
37
|
-
methods: {
|
|
38
|
-
getData () {
|
|
39
|
-
this.$Loading.start();
|
|
40
|
-
$.ajax({
|
|
41
|
-
url: '/api/someurl',
|
|
42
|
-
type: 'get',
|
|
43
|
-
success: () => {
|
|
44
|
-
this.$Loading.finish();
|
|
45
|
-
}
|
|
46
|
-
error: () => {
|
|
47
|
-
this.$Loading.error();
|
|
48
|
-
},
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
```
|
|
54
|
-
|
|
1
|
+
# Loading 加载进度
|
|
2
|
+
进度加载。
|
|
3
|
+
|
|
4
|
+
## 何时使用
|
|
5
|
+
- 异步请求时展示进度
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## 示例
|
|
9
|
+
|
|
10
|
+
模拟路由加载
|
|
11
|
+
```js
|
|
12
|
+
// # router.js
|
|
13
|
+
|
|
14
|
+
import Vue from 'vue'
|
|
15
|
+
import Router from 'vue-router'
|
|
16
|
+
import kui from 'kui-vue'
|
|
17
|
+
|
|
18
|
+
Vue.use(Router)
|
|
19
|
+
let router = new Router({
|
|
20
|
+
....
|
|
21
|
+
})
|
|
22
|
+
router.beforeEach((to, from, next) => {
|
|
23
|
+
kui.Loading.start();
|
|
24
|
+
next();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
router.afterEach(route => {
|
|
28
|
+
kui.Loading.finish();
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
模拟ajax 请求
|
|
33
|
+
```js
|
|
34
|
+
// 以jQuery的Ajax为例,部分代码省略
|
|
35
|
+
import $ from 'jquery';
|
|
36
|
+
export default {
|
|
37
|
+
methods: {
|
|
38
|
+
getData () {
|
|
39
|
+
this.$Loading.start();
|
|
40
|
+
$.ajax({
|
|
41
|
+
url: '/api/someurl',
|
|
42
|
+
type: 'get',
|
|
43
|
+
success: () => {
|
|
44
|
+
this.$Loading.finish();
|
|
45
|
+
}
|
|
46
|
+
error: () => {
|
|
47
|
+
this.$Loading.error();
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
55
|
## 代码演示
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
### Loading API
|
|
2
|
-
| 属性 | 说明 | 类型 | 默认值 |
|
|
3
|
-
|---------|------------------|-------------------|--------|
|
|
4
|
-
| start | 开始加载 | Function | - |
|
|
5
|
-
| finish | 完成加载 | Function | - |
|
|
6
|
-
| error | 加载错误 | Function | - |
|
|
7
|
-
| update | 手动更新进度 | Function(percent) | - |
|
|
1
|
+
### Loading API
|
|
2
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
3
|
+
|---------|------------------|-------------------|--------|
|
|
4
|
+
| start | 开始加载 | Function | - |
|
|
5
|
+
| finish | 完成加载 | Function | - |
|
|
6
|
+
| error | 加载错误 | Function | - |
|
|
7
|
+
| update | 手动更新进度 | Function(percent) | - |
|
|
8
8
|
| destroy | vue的$.destroy() | Function | - |
|
|
@@ -30,6 +30,9 @@
|
|
|
30
30
|
color: @main;
|
|
31
31
|
border-color: @main;
|
|
32
32
|
}
|
|
33
|
+
.k-radio-wrapper {
|
|
34
|
+
margin-right: 16px;
|
|
35
|
+
}
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
.k-radio-cirle {
|
|
@@ -108,7 +111,7 @@
|
|
|
108
111
|
}
|
|
109
112
|
}
|
|
110
113
|
.k-radio-label {
|
|
111
|
-
padding:
|
|
114
|
+
padding-left: 8px;
|
|
112
115
|
vertical-align: middle;
|
|
113
116
|
}
|
|
114
117
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
<cn>
|
|
2
|
-
#### 基本用法
|
|
3
|
-
最简单的用法。
|
|
4
|
-
</cn>
|
|
5
|
-
|
|
6
|
-
```vue
|
|
7
|
-
<template>
|
|
8
|
-
<div>
|
|
9
|
-
<Rate />
|
|
10
|
-
</div>
|
|
11
|
-
</template>
|
|
1
|
+
<cn>
|
|
2
|
+
#### 基本用法
|
|
3
|
+
最简单的用法。
|
|
4
|
+
</cn>
|
|
5
|
+
|
|
6
|
+
```vue
|
|
7
|
+
<template>
|
|
8
|
+
<div>
|
|
9
|
+
<Rate />
|
|
10
|
+
</div>
|
|
11
|
+
</template>
|
|
12
12
|
```
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import Info from "./info";
|
|
3
|
-
import Base from "./base";
|
|
4
|
-
import Half from "./half";
|
|
5
|
-
import Tips from "./tips";
|
|
6
|
-
import Disabled from "./disabled";
|
|
7
|
-
import Clear from "./clear";
|
|
8
|
-
import Character from "./character";
|
|
9
|
-
import Custom from "./custom";
|
|
10
|
-
|
|
11
|
-
import CN from "../index.md";
|
|
12
|
-
export default {
|
|
13
|
-
render() {
|
|
14
|
-
return (
|
|
15
|
-
<div class="switch-demo">
|
|
16
|
-
<Info class="typo" />
|
|
17
|
-
<Base />
|
|
18
|
-
<Half />
|
|
19
|
-
<Tips />
|
|
20
|
-
<Disabled />
|
|
21
|
-
<Clear />
|
|
22
|
-
<Character />
|
|
23
|
-
<Custom />
|
|
24
|
-
<CN class="typo" />
|
|
25
|
-
</div>
|
|
26
|
-
);
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
</script>
|
|
1
|
+
<script>
|
|
2
|
+
import Info from "./info";
|
|
3
|
+
import Base from "./base";
|
|
4
|
+
import Half from "./half";
|
|
5
|
+
import Tips from "./tips";
|
|
6
|
+
import Disabled from "./disabled";
|
|
7
|
+
import Clear from "./clear";
|
|
8
|
+
import Character from "./character";
|
|
9
|
+
import Custom from "./custom";
|
|
10
|
+
|
|
11
|
+
import CN from "../index.md";
|
|
12
|
+
export default {
|
|
13
|
+
render() {
|
|
14
|
+
return (
|
|
15
|
+
<div class="switch-demo">
|
|
16
|
+
<Info class="typo" />
|
|
17
|
+
<Base />
|
|
18
|
+
<Half />
|
|
19
|
+
<Tips />
|
|
20
|
+
<Disabled />
|
|
21
|
+
<Clear />
|
|
22
|
+
<Character />
|
|
23
|
+
<Custom />
|
|
24
|
+
<CN class="typo" />
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
</script>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# Rate评分
|
|
2
|
-
评分组件。
|
|
3
|
-
|
|
4
|
-
## 何时使用
|
|
5
|
-
- 对评价进行展示。
|
|
6
|
-
- 对事物进行快速的评级操作。
|
|
7
|
-
|
|
1
|
+
# Rate评分
|
|
2
|
+
评分组件。
|
|
3
|
+
|
|
4
|
+
## 何时使用
|
|
5
|
+
- 对评价进行展示。
|
|
6
|
+
- 对事物进行快速的评级操作。
|
|
7
|
+
|
|
8
8
|
## 代码演示
|
package/components/rate/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import Rate from './rate'
|
|
1
|
+
import Rate from './rate'
|
|
2
2
|
export default Rate
|
package/components/rate/index.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
### Rate API
|
|
2
|
-
| 属性 | 说明 | 类型 | 默认值 |
|
|
3
|
-
| -------------- | ---------------------- | ----------------------- | ------ |
|
|
4
|
-
| value(v-model) | 当前数,受控值 | Number | - |
|
|
5
|
-
| allowClear | 是否允许再次点击后清除 | Boolean | false |
|
|
6
|
-
| allowHalf | 是否允许半选 | Boolean | - |
|
|
7
|
-
| showScore | 是否显示分数 | Boolean | - |
|
|
8
|
-
| character | 自定义字符 | String | - |
|
|
9
|
-
| count | star 总数 | Number | - |
|
|
10
|
-
| disabled | 只读,无法进行交互 | String | - |
|
|
11
|
-
| tooltips | 自定义每项的提示信息 | String[] | - |
|
|
1
|
+
### Rate API
|
|
2
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
3
|
+
| -------------- | ---------------------- | ----------------------- | ------ |
|
|
4
|
+
| value(v-model) | 当前数,受控值 | Number | - |
|
|
5
|
+
| allowClear | 是否允许再次点击后清除 | Boolean | false |
|
|
6
|
+
| allowHalf | 是否允许半选 | Boolean | - |
|
|
7
|
+
| showScore | 是否显示分数 | Boolean | - |
|
|
8
|
+
| character | 自定义字符 | String | - |
|
|
9
|
+
| count | star 总数 | Number | - |
|
|
10
|
+
| disabled | 只读,无法进行交互 | String | - |
|
|
11
|
+
| tooltips | 自定义每项的提示信息 | String[] | - |
|
|
12
12
|
| change | 选择时的回调 | Function(value:number)) | - |
|
package/components/rate/rate.jsx
CHANGED
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
import Tooltip from "../tooltip"
|
|
2
|
-
import Star from './star'
|
|
3
|
-
export default {
|
|
4
|
-
name: 'Rate',
|
|
5
|
-
props: {
|
|
6
|
-
value: { type: Number, default: 0 },
|
|
7
|
-
allowClear: { type: Boolean, default: true },
|
|
8
|
-
allowHalf: Boolean,
|
|
9
|
-
character: [String, Function],
|
|
10
|
-
icon: [String, Function],
|
|
11
|
-
count: { type: Number, default: 5 },
|
|
12
|
-
disabled: Boolean,
|
|
13
|
-
tooltips: Array,
|
|
14
|
-
showScore: Boolean
|
|
15
|
-
},
|
|
16
|
-
data() {
|
|
17
|
-
return {
|
|
18
|
-
defaultValue: this.value,
|
|
19
|
-
tempValue: this.value,
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
render() {
|
|
24
|
-
let { count, tempValue, allowHalf, character, disabled, tooltips = [], icon, showScore } = this
|
|
25
|
-
const stars = []
|
|
26
|
-
if (Number(count) == NaN || count <= 0) {
|
|
27
|
-
count = 5
|
|
28
|
-
}
|
|
29
|
-
if (count > 15) count = 15
|
|
30
|
-
|
|
31
|
-
for (let i = 0; i < count; i++) {
|
|
32
|
-
let v = parseInt(tempValue * 100 - i * 100)
|
|
33
|
-
let percent = tempValue > i && tempValue < i + 1 ? v : 0
|
|
34
|
-
// let show_percent = percent != 50 && disabled && percent > 0
|
|
35
|
-
let half = (tempValue > i && tempValue < i + 1 && allowHalf) || (percent == 50 )
|
|
36
|
-
// console.log(i, percent, show_percent, half)
|
|
37
|
-
let props = {
|
|
38
|
-
props: {
|
|
39
|
-
allowHalf,
|
|
40
|
-
full: tempValue > i && !half ,
|
|
41
|
-
half,
|
|
42
|
-
icon, character,
|
|
43
|
-
disabled,
|
|
44
|
-
value: i,
|
|
45
|
-
percent,
|
|
46
|
-
tooltips: tooltips[i],
|
|
47
|
-
},
|
|
48
|
-
key: i,
|
|
49
|
-
on: {
|
|
50
|
-
click: this.click,
|
|
51
|
-
mouseenter: this.mouseenter,
|
|
52
|
-
mouseleave: this.mouseleave,
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
stars.push(<Star {...props} />)
|
|
56
|
-
}
|
|
57
|
-
let props = {
|
|
58
|
-
class: "k-rate",
|
|
59
|
-
on: { mouseleave: this.reset }
|
|
60
|
-
}
|
|
61
|
-
return (
|
|
62
|
-
<div {...props}>
|
|
63
|
-
{stars}
|
|
64
|
-
{disabled && showScore ? <span class="k-rate-score">{this.value}</span> : null}
|
|
65
|
-
</div>
|
|
66
|
-
)
|
|
67
|
-
},
|
|
68
|
-
methods: {
|
|
69
|
-
reset() {
|
|
70
|
-
this.tempValue = this.defaultValue
|
|
71
|
-
},
|
|
72
|
-
click(index) {
|
|
73
|
-
index = index + 1
|
|
74
|
-
// console.log(index, this.defaultValue)
|
|
75
|
-
if (this.defaultValue && this.allowClear && index == this.defaultValue) {
|
|
76
|
-
index = 0
|
|
77
|
-
}
|
|
78
|
-
if (this.defaultValue != index) {
|
|
79
|
-
this.$emit('change', index)
|
|
80
|
-
}
|
|
81
|
-
this.defaultValue = index
|
|
82
|
-
this.tempValue = index
|
|
83
|
-
|
|
84
|
-
this.$emit('input', index)
|
|
85
|
-
},
|
|
86
|
-
mouseenter(index) {
|
|
87
|
-
// index = index + 1
|
|
88
|
-
this.tempValue = index + 1
|
|
89
|
-
},
|
|
90
|
-
mouseleave(index) {
|
|
91
|
-
// console.log(this.value)
|
|
92
|
-
}
|
|
93
|
-
}
|
|
1
|
+
import Tooltip from "../tooltip"
|
|
2
|
+
import Star from './star'
|
|
3
|
+
export default {
|
|
4
|
+
name: 'Rate',
|
|
5
|
+
props: {
|
|
6
|
+
value: { type: Number, default: 0 },
|
|
7
|
+
allowClear: { type: Boolean, default: true },
|
|
8
|
+
allowHalf: Boolean,
|
|
9
|
+
character: [String, Function],
|
|
10
|
+
icon: [String, Function],
|
|
11
|
+
count: { type: Number, default: 5 },
|
|
12
|
+
disabled: Boolean,
|
|
13
|
+
tooltips: Array,
|
|
14
|
+
showScore: Boolean
|
|
15
|
+
},
|
|
16
|
+
data() {
|
|
17
|
+
return {
|
|
18
|
+
defaultValue: this.value,
|
|
19
|
+
tempValue: this.value,
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
render() {
|
|
24
|
+
let { count, tempValue, allowHalf, character, disabled, tooltips = [], icon, showScore } = this
|
|
25
|
+
const stars = []
|
|
26
|
+
if (Number(count) == NaN || count <= 0) {
|
|
27
|
+
count = 5
|
|
28
|
+
}
|
|
29
|
+
if (count > 15) count = 15
|
|
30
|
+
|
|
31
|
+
for (let i = 0; i < count; i++) {
|
|
32
|
+
let v = parseInt(tempValue * 100 - i * 100)
|
|
33
|
+
let percent = tempValue > i && tempValue < i + 1 ? v : 0
|
|
34
|
+
// let show_percent = percent != 50 && disabled && percent > 0
|
|
35
|
+
let half = (tempValue > i && tempValue < i + 1 && allowHalf) || (percent == 50 )
|
|
36
|
+
// console.log(i, percent, show_percent, half)
|
|
37
|
+
let props = {
|
|
38
|
+
props: {
|
|
39
|
+
allowHalf,
|
|
40
|
+
full: tempValue > i && !half ,
|
|
41
|
+
half,
|
|
42
|
+
icon, character,
|
|
43
|
+
disabled,
|
|
44
|
+
value: i,
|
|
45
|
+
percent,
|
|
46
|
+
tooltips: tooltips[i],
|
|
47
|
+
},
|
|
48
|
+
key: i,
|
|
49
|
+
on: {
|
|
50
|
+
click: this.click,
|
|
51
|
+
mouseenter: this.mouseenter,
|
|
52
|
+
mouseleave: this.mouseleave,
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
stars.push(<Star {...props} />)
|
|
56
|
+
}
|
|
57
|
+
let props = {
|
|
58
|
+
class: "k-rate",
|
|
59
|
+
on: { mouseleave: this.reset }
|
|
60
|
+
}
|
|
61
|
+
return (
|
|
62
|
+
<div {...props}>
|
|
63
|
+
{stars}
|
|
64
|
+
{disabled && showScore ? <span class="k-rate-score">{this.value}</span> : null}
|
|
65
|
+
</div>
|
|
66
|
+
)
|
|
67
|
+
},
|
|
68
|
+
methods: {
|
|
69
|
+
reset() {
|
|
70
|
+
this.tempValue = this.defaultValue
|
|
71
|
+
},
|
|
72
|
+
click(index) {
|
|
73
|
+
index = index + 1
|
|
74
|
+
// console.log(index, this.defaultValue)
|
|
75
|
+
if (this.defaultValue && this.allowClear && index == this.defaultValue) {
|
|
76
|
+
index = 0
|
|
77
|
+
}
|
|
78
|
+
if (this.defaultValue != index) {
|
|
79
|
+
this.$emit('change', index)
|
|
80
|
+
}
|
|
81
|
+
this.defaultValue = index
|
|
82
|
+
this.tempValue = index
|
|
83
|
+
|
|
84
|
+
this.$emit('input', index)
|
|
85
|
+
},
|
|
86
|
+
mouseenter(index) {
|
|
87
|
+
// index = index + 1
|
|
88
|
+
this.tempValue = index + 1
|
|
89
|
+
},
|
|
90
|
+
mouseleave(index) {
|
|
91
|
+
// console.log(this.value)
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
94
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<cn>
|
|
2
|
+
#### 基本用法
|
|
3
|
+
基本用法
|
|
4
|
+
</cn>
|
|
5
|
+
|
|
6
|
+
```vue
|
|
7
|
+
<template>
|
|
8
|
+
<div>
|
|
9
|
+
<Slider value="30"/>
|
|
10
|
+
<Slider value="30" disabled/>
|
|
11
|
+
<br/>
|
|
12
|
+
<br/>
|
|
13
|
+
<Space>
|
|
14
|
+
<Slider min="1" v-model="v" max="10"/>
|
|
15
|
+
<Input v-model="v" size="small" style="width:60px">
|
|
16
|
+
</Space>
|
|
17
|
+
<br/>
|
|
18
|
+
<br/>
|
|
19
|
+
<Space>
|
|
20
|
+
<Slider min="1" v-model="v2" max="10" :step="0.1"/>
|
|
21
|
+
<Input v-model="v2" size="small" style="width:60px">
|
|
22
|
+
</Space>
|
|
23
|
+
</div>
|
|
24
|
+
</template>
|
|
25
|
+
<script>
|
|
26
|
+
export default{
|
|
27
|
+
data(){
|
|
28
|
+
return{
|
|
29
|
+
v:3,
|
|
30
|
+
v2:3.5
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
</script>
|
|
35
|
+
```
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import Info from "./info";
|
|
3
|
+
import Base from "./base";
|
|
4
|
+
// import Vertical from "./vertical";
|
|
5
|
+
|
|
6
|
+
import CN from "../index.md";
|
|
7
|
+
export default {
|
|
8
|
+
render() {
|
|
9
|
+
return (
|
|
10
|
+
<div class="switch-demo">
|
|
11
|
+
<Info class="typo" />
|
|
12
|
+
<Base />
|
|
13
|
+
<CN class="typo" />
|
|
14
|
+
</div>
|
|
15
|
+
);
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
</script>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
### Slider API
|
|
2
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
3
|
+
| ------ | -------------------------------------------------------------------------- | ----------------------------------------------- | ------ |
|
|
4
|
+
| min | 最小值 | number | 0 |
|
|
5
|
+
| max | 最大值 | number | 100 |
|
|
6
|
+
| step | 间距大小 | 步长,取值必须大于 0,并且可被 (max - min) 整除 | 1 |
|
|
7
|
+
| change | 当 Slider 的值发生改变时,会触发 change 事件,并把改变后的值作为参数传入。 | Function | - |
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
props: {
|
|
3
|
+
value: [String, Number],
|
|
4
|
+
min: { type: [Number, String], default: 0 },
|
|
5
|
+
max: { type: [Number, String], default: 100 },
|
|
6
|
+
disabled: Boolean,
|
|
7
|
+
step: {
|
|
8
|
+
type: [Number, String],
|
|
9
|
+
default: 1,
|
|
10
|
+
validator: (val) => val > 0
|
|
11
|
+
},
|
|
12
|
+
direction: {
|
|
13
|
+
//todo:
|
|
14
|
+
type: String,
|
|
15
|
+
default: 'horizontal',
|
|
16
|
+
validator: (val) => ['horizontal', 'vertical'].indexOf(val) >= 0
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
data() {
|
|
20
|
+
return {
|
|
21
|
+
defaultValue: this.value || 0,
|
|
22
|
+
timer: null,
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
methods: {
|
|
26
|
+
change(e) {
|
|
27
|
+
let value = e.target.value * 1
|
|
28
|
+
this.defaultValue = value
|
|
29
|
+
this.$emit('input', value)
|
|
30
|
+
|
|
31
|
+
clearTimeout(this.timer)
|
|
32
|
+
this.timer = setTimeout(() => {
|
|
33
|
+
this.$emit('change', value)
|
|
34
|
+
}, 300);
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
render() {
|
|
38
|
+
let { min, max, step, disabled, direction } = this
|
|
39
|
+
let props = {
|
|
40
|
+
class: 'k-slider-bar',
|
|
41
|
+
attrs: {
|
|
42
|
+
min, max, step,
|
|
43
|
+
value: this.defaultValue,
|
|
44
|
+
type: 'range',
|
|
45
|
+
disabled,
|
|
46
|
+
},
|
|
47
|
+
style: {
|
|
48
|
+
'background': `linear-gradient(to right, #3a95ff ${(this.defaultValue - min) / (max - min) * 100}%, rgba(255, 255, 255, 0.3) 0%)`
|
|
49
|
+
},
|
|
50
|
+
on: {
|
|
51
|
+
input: this.change
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// todo: 懒得写, 用input range 替代, 等需求复杂了, 再继续写更多
|
|
55
|
+
return <div class={['k-slider', { 'k-slider-disabled': disabled }]}><input {...props} /></div>
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
}
|