Commit 53e38f9c62e6c54d555bdf8dd591aafe9a93f079

Authored by Rijn
1 parent 50f4ac70

added prop validators

Showing 1 changed file with 17 additions and 5 deletions   Show diff stats
src/components/carousel/carousel.vue
... ... @@ -24,7 +24,7 @@
24 24 </template>
25 25 <script>
26 26 import Icon from '../icon/icon.vue';
27   - import { getStyle } from '../../utils/assist';
  27 + import { getStyle, oneOf } from '../../utils/assist';
28 28  
29 29 const prefixCls = 'ivu-carousel';
30 30  
... ... @@ -34,7 +34,10 @@
34 34 props: {
35 35 arrow: {
36 36 type: String,
37   - default: 'hover'
  37 + default: 'hover',
  38 + validator (value) {
  39 + return oneOf(value, ['hover', 'always', 'never']);
  40 + }
38 41 },
39 42 autoplay: {
40 43 type: Boolean,
... ... @@ -50,11 +53,17 @@
50 53 },
51 54 dots: {
52 55 type: String,
53   - default: 'inside'
  56 + default: 'inside',
  57 + validator (value) {
  58 + return oneOf(value, ['inside', 'outside', 'none']);
  59 + }
54 60 },
55 61 trigger: {
56 62 type: String,
57   - default: 'click'
  63 + default: 'click',
  64 + validator (value) {
  65 + return oneOf(value, ['click', 'hover']);
  66 + }
58 67 },
59 68 currentIndex: {
60 69 type: Number,
... ... @@ -62,7 +71,10 @@
62 71 },
63 72 height: {
64 73 type: [String, Number],
65   - default: 'auto'
  74 + default: 'auto',
  75 + validator (value) {
  76 + return value === 'auto' || toString.call(value) === '[object Number]';
  77 + }
66 78 }
67 79 },
68 80 data () {
... ...