js 输出数据类型为decimal(18, 2),加0


<script>
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>
<script type="text/html" id="tplMoney">{{fixed(d.inputMoney)}}</script>
数据表格列设置
{field: 'inputMoney', title: '投入总资金', width: 105, templet: '#tplMoney'}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM