Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

175
Views
establezca la fecha de golpe dos días antes de la fecha de entrega en vue.js

Soy nuevo en vue.js. Tengo un formulario que tiene dos campos de entrada de fecha como Fecha de entrega y Fecha de golpe .

Quiero configurar la fecha de golpe automáticamente dos días antes de la fecha de entrega. Por ejemplo, si la fecha de entrega es el 20/9/2021, la fecha de entrega debe ser el 18/9/2021.

¿Cómo implementar esto en vue.js?

Estos son los campos del formulario que se indican a continuación:

 <template> <form> <label for="">PO Delivery Date</label> <input class="form-control" type="date" v-model="PO_DeliveryData" v-validate="'required'" placeholder="PO Delivery Date" /><br /> <label for="">Knock Date</label> <input class="form-control" type="date" v-model="knock_Date" v-validate="'required'" placeholder="Knock Date" /><br /> </form> </template> <script> export defaults:{ } </script>
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Es fácil de calcular con momentjs

 <template> <form> <label for="">PO Delivery Date</label> <input v-model="deliveryDate" class="form-control" type="date" placeholder="PO Delivery Date" /><br /> <label for="">Knock Date</label> <input :value="knockDate" class="form-control" type="date" placeholder="Knock Date" /> <pre>deliveryDate: {{ deliveryDate }}</pre> <pre>knockDate: {{ knockDate }}</pre> </form> </template> <script> import moment from "moment"; export default { name: "App", data: () => { return { deliveryDate: "", knockDate: "", }; }, watch: { deliveryDate(val) { if (val) { this.knockDate = moment(val, "YYYY-MM-DD") .subtract(2, "day") .format("YYYY-MM-DD"); } else { this.knockDate = ""; } }, }, }; </script>
about 4 years ago · Juan Pablo Isaza Report

0

Prueba como el siguiente fragmento:

 new Vue({ el: '#demo', data() { return { PO_DeliveryData: '', knock_Date: '' } }, watch: { PO_DeliveryData() { let d = new Date(this.PO_DeliveryData); d.setDate(d.getDate() - 2); this.knock_Date = d.toISOString().slice(0, 10) } } })
 <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script> <div id="demo"> <form> <label for="">PO Delivery Date</label> <input class="form-control" type="date" v-model="PO_DeliveryData" placeholder="PO Delivery Date" /><br /> <label for="">Knock Date</label> <input class="form-control" type="date" v-model="knock_Date" placeholder="Knock Date" /><br /> </form> </div>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!