1,新建一个wxs文件
var numberUtil = {
numberFormat: function (num){
if(num>=100000000){
return (num/10000000).toFixed(1)+"亿"
}else if(num>=10000){
return (num/100000).toFixed(1)+"万"
}
}
}
module.exports = {
numberFormat: numberUtil.numberFormat//暴露接口调用
}
2,wxml文件中导入
<wxs module="numberUtil" src="../../utils/util.wxs"></wxs>
3,使用
<text>{{numberUtil.numberFormat(item.playCount)}}</text>