1

My vue component, you can see this below :

<template>
    <div>
        <div class="col-sm-2">
            <div class="form-group">
                <input v-model="fromDate" data-date-format="DD-MM-YYYY" title="DD-MM-YYYY" type="text" class="form-control" placeholder="Date" name="to_date" id="datetimepicker" required>
            </div>
        </div>
        <div class="col-sm-1">
            <div class="form-group" style="text-align: center">
                -
            </div>
        </div>
        <div class="col-sm-2">
            <div class="form-group">                           
                <input v-model="toDate" data-date-format="DD-MM-YYYY" title="DD-MM-YYYY" type="text" class="form-control" placeholder="Date" name="to_date" id="datetimepicker" required>
            </div>
        </div>
        <div class="col-sm-4">
            <button v-on:click="filter()" class="btn btn-default" type="button">
                <span class="glyphicon glyphicon-search"></span>
            </button>
        </div>
    </div>
</template>
<script>
    export default {
        data() {
            return{
                fromDate: '',
                toDate: ''
            }
        },
        methods: {
            filter: function() {
                console.log(this.fromDate)
                console.log(this.toDate)
            }
        }
    }
</script>

When I select datepicker and click search button, it does not success to get value of datepicker

I try console.log, but the result empty

Is there anyone who can help me?

8
  • Possible duplicate of How can I get value in datepicker on vue component? Commented Apr 5, 2017 at 12:08
  • Your code work fine for me - console logs inputs on button click. Commented Apr 5, 2017 at 12:41
  • @wostex, How can you try it? In my localhost, it does not display Commented Apr 5, 2017 at 12:56
  • @Potray, This question little different Commented Apr 5, 2017 at 13:00
  • I've just pasted it into my single file component and it does what intended. Is this just this component or may be your application is set up wrong? Try to replicate your problem on jsfiddle. Commented Apr 5, 2017 at 13:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.