微信小程序——過濾器的模擬


>> 編寫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