【发布时间】:2019-04-01 15:00:46
【问题描述】:
我正在使用Laravel 5.7 & VueJs 2.5.* ...
我想在我的视图表上显示GrandTotal,但我不知道我做错了什么。
我在哪里显示GrandTotal:
<tr v-for="ctInvoice in ctInvoices" :key="ctInvoice.id">
<td>{{ formatPrice(ctInvoice.ct_invoice_grand_total) }}</td>
</tr>
我的VueJsdata():
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
},
ctInvoices 数组的一项输出
ctInvoices:数组[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:Array1 ct_invoice_no:"111-222-333" 客户:对象 客户 ID:3 编号:22 更新时间:“2018-10-27 15:13:06”
【问题讨论】:
-
你为什么要
replace(".", ".");? -
我不知道我只是想以金钱的形式展示我的价值,所以我提出了问题,一个人给了我
formatMoneymethod()。 -
你能给我介绍一下那个问题吗?
-
@BoussadjraBrahim 在这里,stackoverflow.com/questions/43208012/…
-
在你的情况下你正在做
let val = (value / 1).toFixed().replace(".", ".");,但在给定的问题中有let val = (value / 1).toFixed().replace(".", ",");
标签: javascript html laravel vue.js vuejs2