输入
11
2.7777777
8.1
输出:
11
2.78
8.1
我想要舍入到小数点后2位,但仅在必要时。
我如何在JavaScript中执行此操作?
答案 0 :(得分:2)
使用Math.round(num * 100) / 100
答案 1 :(得分:-1)
请在此处查看{
title: "operation",
width: 400,
lockable: false,
template: "
<a title=edit class=\"primary-color knd-custom-action-btn\" href=\"\\#/restaurants/edit/${restaurantId}\" >BrunchCode</a>
<a class=\"primary-color knd-custom-action-btn\" href=\"\\#/restaurants/edit/${restaurantId}\" ><i class=\"fa fa-pencil\"></i></a>
"
}
文档:toFixed()
toFixed()