When the nown variable nown changed, the beginDate variable beginDate .

Why is that?

CodeSabdbox

 <template> <div> <datepicker v-model="beginDate" v-bind:disabled="nowd" format="MM/dd/yyyy"></datepicker> <datepicker :value.sync="nown.to" v-bind:disabled="nown" format="MM/dd/yyyy"></datepicker> </div> </template> <script> import Datepicker from "vuejs-datepicker"; export default { name: "form", components: { Datepicker }, data() { return { msg: "Form", beginDate: new Date() }; }, computed: { nowd: function() { let currentDate = new Date(); currentDate.setDate(currentDate.getDate() - 1); return { to: currentDate }; }, nown: function() { let currentDate = this.beginDate; currentDate.setDate(currentDate.getDate() + 14); return { to: currentDate }; } } }; </script> <style> </style> 

    1 answer 1

    This is because you are using assignment.

     let currentDate = this.beginDate; 

    Since the value is an object, the link is copied and not the value. You need to clone an object to create a new object that will be used by another date picker.

    • ATP, I just realized that it was time to sleep, because I do not notice such silly mistakes) - DemoGosha