javascript - 打印 HTML 页面时会添加额外的零

标签 javascript c# html

我正在尝试从 HTML 页面打印 3 个以下;问题是@a.Invoice.TotalAmount 在一个数字之后追加 4 个额外的零,例如到 12 它显示为 12.0000 到 18.54 它显示 18.5400 和 11.1 为 11.1000。

<tr>
        <td style="width: 50%; text-align: left; font-size: 12px;">@a.Invoice.InvoiceVendor.Name</td>
        <td style="font-size: 12px;">@a.Invoice.InvoiceNumber</td>
        <td style="font-size: 12px;">@a.Invoice.TotalAmount</td>
    </tr>

当我调试代码 (html) 时,没有显示页面零。 enter image description here

但是当我打印页面时,它带有尾随零

enter image description here

我担心的是我不需要小数点后的零。有什么建议吗?

谢谢。

最佳答案

尝试使用 JavaScript 方法 toFixed(2) 显示它

例如。

var num = 5.56789;
var n = num.toFixed(2);

阅读更多:https://www.w3schools.com/jsref/jsref_tofixed.asp

关于javascript - 打印 HTML 页面时会添加额外的零,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43566714/

相关文章:

java - 创建运行java的cmd进程

javascript - 按钮切换显示显示隐藏

javascript - 金融应用程序的外汇汇率

javascript - Node.js 中的 map(),异步与同步?

c# - 在 C# .net 中发送邮件失败

html - 将 div 放置在另一个 div 的底部

jquery - 将所有子项设置为最大子项的高度

javascript - 锁定对 Angular 线运动

javascript - 即使被注释掉,jQuery 代码仍然会被执行

c# - WF 4 : difference between ActivityAction or ActivityFunc and child activity