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,7 +24,7 @@
24 </template> 24 </template>
25 <script> 25 <script>
26 import Icon from '../icon/icon.vue'; 26 import Icon from '../icon/icon.vue';
27 - import { getStyle } from '../../utils/assist'; 27 + import { getStyle, oneOf } from '../../utils/assist';
28 28
29 const prefixCls = 'ivu-carousel'; 29 const prefixCls = 'ivu-carousel';
30 30
@@ -34,7 +34,10 @@ @@ -34,7 +34,10 @@
34 props: { 34 props: {
35 arrow: { 35 arrow: {
36 type: String, 36 type: String,
37 - default: 'hover' 37 + default: 'hover',
  38 + validator (value) {
  39 + return oneOf(value, ['hover', 'always', 'never']);
  40 + }
38 }, 41 },
39 autoplay: { 42 autoplay: {
40 type: Boolean, 43 type: Boolean,
@@ -50,11 +53,17 @@ @@ -50,11 +53,17 @@
50 }, 53 },
51 dots: { 54 dots: {
52 type: String, 55 type: String,
53 - default: 'inside' 56 + default: 'inside',
  57 + validator (value) {
  58 + return oneOf(value, ['inside', 'outside', 'none']);
  59 + }
54 }, 60 },
55 trigger: { 61 trigger: {
56 type: String, 62 type: String,
57 - default: 'click' 63 + default: 'click',
  64 + validator (value) {
  65 + return oneOf(value, ['click', 'hover']);
  66 + }
58 }, 67 },
59 currentIndex: { 68 currentIndex: {
60 type: Number, 69 type: Number,
@@ -62,7 +71,10 @@ @@ -62,7 +71,10 @@
62 }, 71 },
63 height: { 72 height: {
64 type: [String, Number], 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 data () { 80 data () {