added prop validators

This commit is contained in:
Rijn 2017-01-17 20:03:49 -06:00
parent 50f4ac7088
commit 53e38f9c62

View file

@ -24,7 +24,7 @@
</template> </template>
<script> <script>
import Icon from '../icon/icon.vue'; import Icon from '../icon/icon.vue';
import { getStyle } from '../../utils/assist'; import { getStyle, oneOf } from '../../utils/assist';
const prefixCls = 'ivu-carousel'; const prefixCls = 'ivu-carousel';
@ -34,7 +34,10 @@
props: { props: {
arrow: { arrow: {
type: String, type: String,
default: 'hover' default: 'hover',
validator (value) {
return oneOf(value, ['hover', 'always', 'never']);
}
}, },
autoplay: { autoplay: {
type: Boolean, type: Boolean,
@ -50,11 +53,17 @@
}, },
dots: { dots: {
type: String, type: String,
default: 'inside' default: 'inside',
validator (value) {
return oneOf(value, ['inside', 'outside', 'none']);
}
}, },
trigger: { trigger: {
type: String, type: String,
default: 'click' default: 'click',
validator (value) {
return oneOf(value, ['click', 'hover']);
}
}, },
currentIndex: { currentIndex: {
type: Number, type: Number,
@ -62,7 +71,10 @@
}, },
height: { height: {
type: [String, Number], type: [String, Number],
default: 'auto' default: 'auto',
validator (value) {
return value === 'auto' || toString.call(value) === '[object Number]';
}
} }
}, },
data () { data () {