为什么我看不到我的GrandTotal?

时间:2018-10-28 14:36:34

标签: javascript html laravel vue.js vuejs2

我正在使用Laravel 5.7VueJs 2.5.* ...

我想在视图表上显示GrandTotal,但是我不知道自己在做什么错。

我要显示GrandTotal的位置:

<tr v-for="ctInvoice in ctInvoices" :key="ctInvoice.id">
  <td>{{ formatPrice(ctInvoice.ct_invoice_grand_total) }}</td>
</tr>

我的VueJs data()

data() {
    return {
      ctInvoices: {},
      customers: null,
      form: new Form({
        id: "",
        customer_id: "",
        ct_invoice_no: "",
        ct_invoice_date: "",
        ct_invoice_fares_total: 0,
        ct_invoice_taxes_grand_total: 0,
        ct_invoice_grand_total: 0,

        ctInvoiceItems: [{
          id: "",
          ct_invoice_id: "",
          ct_passenger_name: "",
          ct_fares: 0,
          ct_total_tax_breakup: 0,
          ct_sub_total: 0
        }]
      })
    };

使用以下method()格式化金额:

formatPrice(value) {
  let val = (value / 1).toFixed().replace(".", ".");
  return val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); //75.674,00
},

便于更好理解的图像: enter image description here

ctInvoices数组中的一项输出

  

ctInvoices:Array [20]   0:对象   created_at:“ 2018-10-27 15:13:06”   ct_Invoice_date:“ 2018-10-31”   ct_Invoice_fares_total:“ 600.00”   ct_Invoice_grand_total:“ 1000.00”   ct_Invoice_grand_total_words:空   ct_Invoice_taxes_grand_total:“ 400.00”   ct_Invoice_terms:空   ct_invoice_items:数组1   ct_invoice_no:“ 111-222-333”   客户:对象   客户编号:3   编号:22   Updated_at:“ 2018-10-27 15:13:06”

2 个答案:

答案 0 :(得分:1)

您正在打错字,ct_Invoice_grand_total对象中有一个名为ctInvoice的属性,其属性为大写 I ,而您用小写的 i对其进行了调用,因此您应该输入:

     <tr v-for="ctInvoice in ctInvoices" :key="ctInvoice.id">
       <td>{{ formatPrice(ctInvoice.ct_Invoice_grand_total) }}</td>
     </tr>

答案 1 :(得分:0)

您的控制台显示什么错误?

您在数据中将ctInvoice指定为对象,这不应该是其中包含ctInvoice个对象的数组吗?

ctInvoices中的每个ct_invoice_grand_total是否包含Vue.filter('formatNumber', value => { let number = parseFloat(value); let options = { minimumFractionDigits: 2, style: 'currency', currency: 'EUR' }; return number.toLocaleString("nl-NL", options); }); 属性?

您可以使用带有toLocaleString的过滤器来代替使用价格格式化功能。

async