微信小程序——过滤器的模拟


>> 编写wxs文件——filter.wxs

//1. 价格格式化
function getPriceFormat(value) {
  return parseFloat(isNaN(value) ? 0 : value).toFixed(2); } module.exports = { getPriceFormat: getPriceFormat }

>> wxml模板文件中导入过滤器文件:

<wxs module="filter" src="../../filter/filter.wxs"></wxs>

>> 在模板中使用过滤器:

<text class='c_price'>¥{{filter.getPriceFormat(item[index].price)}}</text>


免责声明!

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



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