layui table的数值保留两位小数
Others 2018-04-04 07:02:02 2018-04-04 07:02:02 10161 次浏览function fixed(str) { if (!str) str = '0.00'; let ret = Math.round(parseFloat(str) * 100) / 100; let decimal = ret.toString().split('.'); if (decimal.length === 1) { return ret.toString() + '.00' }; if (decimal.length > 1) { if (decimal[1].length < 2) { return ret.toString() + '0' } return ret }; return ret; } </script>
Links: 118