<template>
    <input class="form-control">
</template>

<script>
    export default {
        props: {
            value: {
                required: false
            }
        },
        mounted(){
            let vm = this;
            $(this.$el).datepicker({
                format: 'dd-mm-yyyy',
                autoclose: true,
                clearBtn: true,
            }).val(this.value).trigger("change").on('changeDate', function(){
                vm.$emit('input', this.value);
            });
        },
        watch: {
            value: function(value){
                $(this.$el).val(value).trigger('change');
            }
        }
    }
</script>