最近搜索

js提供了parseInt()和parseFloat()两个转换函数。

浏览:517
管理员 2019-09-07 14:57

js 相加

浮点  小数点


前者把值转换成整数,int   

后者把值转换成浮点数。float



js  保留2位

t.toFixed(2);



在layui   table 中使用如下

{{#  if(d.xianjin_xiaoshou != null){ }}
	 {{ (d.xianjin_xiaoshou).toFixed(2) }}
  {{#  } else { }}
  {{#  } }}

  
上面不能用,用这个。
<script type="text/html" id="format_shiji">
{{#  if(d.shiji!= null){ }}
{{ parseFloat(d.shiji).toFixed(2) }}
{{#  } }}
</script>
<script type="text/html" id="format_yunxu">
{{#  if(d.yunxu!= null){ }}
{{ parseFloat(d.yunxu).toFixed(2) }}
{{#  } }}
</script>


{{#  if(d.yinlian_heji != null){ }}
	 {{ (d.xianjin_chuzhi+d.jizhang_chuzhi+d.yinlian_chuzhi+d.xianjin_cunyou+d.jizhang_cunyou+d.yinlian_cunyou).toFixed(2) }}
  {{#  } else { }}
  {{#  } }}


var b = parseInt("10.00")


联系站长

站长微信:xiaomao0055

站长QQ:14496453