Micro letter applet wxml page toFixed two decimal places, wxs scripting language

When wxml page to perform the function of toFixed found invalid, in small micro-letter js page program is in effect, but I do not want to keep these additional data in the data in, so to find such a solution the following wxs scripting language .

<wxs module="m1">
  var numberToFix= function (value) {
    return value.toFixed(2)
  }
 module.exports.numberToFix=numberToFix;
</wxs>
<view>toFixed:{{m1.numberToFix(value*3)}}</view>

  

data: {
    value:1.567
 },

  

Guess you like

Origin www.cnblogs.com/gitByLegend/p/11309237.html