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

185
Views
Vue Js: cadena vacía al publicar en API

en mi código a continuación... estoy actualizando datos usando la API REST de Node Js y en el campo remaining he establecido una ecuación usando v-model=remaininginst para realizar un seguimiento del resultado y guardarlo en el resto para poder publicarlo en la API, pero en console.log obtengo datos vacíos de NaN almacenados en el resto del instante y no se están publicando debido a este error.

¿Estoy haciendo algo mal aquí? y si es así, ¿hay alguna manera de hacerlo?

 <h4 v-model="remaininginst"> remain : ${{ Number(instPrice) -(Number(totPaid) + Number(instOne) ) }}</h4> //equation shows coorect data on html </template> export default { name: 'light-table', components: { loader }, data() { return { instPrice: "", remaininginst: "", instOne:"" }; }, computed: { totPaid() { let installments = this.Flats.payment.installment_payment.installments; let paidInstallments = installments.filter(obj => obj.is_paid == true); let totalPaid = paidInstallments.reduce((sum, obj) => sum + parseInt(obj.amount), 0); return totalPaid; } }, methods: { PostPayment() { this.error = [] console.log(this.payment); var data = { payment: { installment_payment: { remaining: this.remaininginst,//getting Nan }, paid_amount: this.instOne, }, } BuildingsService.Payment(this.FlatId, data).then((response) => { console.log(data); }); },

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

No podría usar v-model en la etiqueta h4. Podría intentar crear otra propiedad calculada que contenga la expresión que necesita y mostrarla a la vista. Debajo de la muestra, mueva el remaininginst de data a computed como una propiedad calculada.

 <template> <h4> remain : $ {{ remaininginst }} </h4> </template> <script> export default { data() { return { instPrice: "", instOne: "", }; }, computed: { totPaid() { let installments = this.Flats.payment.installment_payment.installments; let paidInstallments = installments.filter(obj => obj.is_paid == true); let totalPaid = paidInstallments.reduce((sum, obj) => sum + parseInt(obj.amount), 0); return totalPaid; } remaininginst() { return ( Number(this.instPrice) - (Number(this.totPaid) + Number(this.instOne)) );//return any string you want }, }, methods: { PostPayment() { console.log(this.remaininginst); }, }, }; </script>
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!