I am using jQuery date picker and its working perfectly. I am in Vue component. when I click the date input field it shows date picker but when I choose one date and see the result in the console I got nothing. Date is not bind.
<form @submit.prevent="search()">
<div class="card">
<div class="card-body">
<div class="card-header"></div>
<div class="card-body">
<div class="row">
<div class="col-md-8">
<input type="text" v-model="date" class="form-control" id="datepicker" >
</div>
<div class="col-md-4">
<button class="btn btn-primary" >Search</button>
</div>
</div>
</div>
</div>
</div>
</form>
<script>
export default {
data(){
return{
date:''
}
},
mounted() {
console.log('Component mounted.')
},
methods:{
search(){
//I want to get user chooses date here so that I can send to endpoint
console.log(this.date)//got nothing here
},
},
}
</script
when i click the search button , i should get the date in console but i got nothing, How to get current selected date by user? Thank you
You can bind the input inside
mounted
hook with the jquery date picker.Note:
this.date
will not work inside the jquery blocks. So an instance should be defined to assign with vue.