小程序在wxml页面中取整


小程序无法像html中,在页面中直接parseInt()

  • index.wxml
{{price | Int}}

小程序还有另一种处理方法
wxs 是一种类似于js脚本的东西

  • filters.wxs
var filters = {
    toFix: function (value) {
        return parseFloat(value)
    }
}
module.exports = {
    toFix: filters.toFix
}

-index.wxml

<wxs module="filters" src="../filters.wxs"></wxs>
<view class="price">
       <text>¥</text>{{filters.toFix(lesson.price)}}
</view>


免责声明!

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



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