-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathEditorInt.vue
49 lines (47 loc) · 1.19 KB
/
EditorInt.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<template>
<EditorNumber
ref="EditorNumber"
v-bind="$attrs"
v-model="model"
v-on="listenersWithoutInput"
/>
</template>
<script>
import _listeners_without_input_mixin from './_listeners_without_input_mixin';
export default {
name: 'EditorInt',
components: {
EditorNumber: () => import('./EditorNumber'),
},
mixins: [
_listeners_without_input_mixin,
],
props: {
value: {
type: Number,
required: true,
validator (val) {
return Number.isInteger(val);
},
},
},
computed: {
model: {
get () {
return this.value;
},
set (val) {
if (Number.isInteger(val)) {
this.$emit('input', val);
} else {
this.$nextTick(() => {
// 有点hack element-ui底层的坑
const inputNumber = this.$refs.EditorNumber.$refs.number;
inputNumber.setCurrentValue(Number.parseInt(val));
});
}
},
},
},
};
</script>