1
I am faced with difficulty when setting settings for the component that uses jquery in vuejs2.
<div id="app">
<date-picker @update-date="updateDate" timepicker= "false" v-once></date-picker>
<p>{{ date }}</p>
</div>
<script>
Vue.component('date-picker', {
template: '<input/>',
props: [ 'timepicker' ],
mounted: function() {
var self = this;
$(this.$el).datetimepicker({
timepicker: this.timepicker,
onSelect: function(date) {
self.$emit('update-date', date);
}
});
},
beforeDestroy: function() {
$(this.$el).datetimepicker('hide').datetimepicker('destroy');
}
});
new Vue({
el: '#app',
data: {
date: null
},
methods: {
updateDate: function(date) {
this.date = date;
}
}
});