第一种,在wxml的行间取小数,转字符串,转数字 首先新建一个后缀为.wxs的文件,如‘filter.wxs’ 1.代码如图所示: 2.在需要的wxml中引入: 3.使用时的方法: 这里使用时,根据自己的需求也可以用定义好的toStr(转为字符串),toNum(转为数字); 第二种,在js中取小数 js代码: var foo = 5.201314; var boo = foo.toFixed(2); console.log(boo); 输出结果为 5.20