Applet wxml micro-channel using function js

 

 

 

 

 

Description link

 

 

 

1. Create a new directory `filter.wxs` under utils

 

var Filters = {     
    toFix: function (value) {       
         return value.toFixed (2) // here 2 to two decimal places, to retain several decimal places, where to write a few     
    }, 
    tostr: function (value) {       
         return value.toString () 
    }, 
    toNum: function (value) {       
         return value.toNumber () 
    }, 
} 
 
module.exports = {    
    toFix: filters.toFix, 
    tostr: filters.toStr, 
    toNum: filters.toNum, // exposed interface calls 
}

 

 

2. WXS introduced in the WXML

 

<wxs module="filters" src="../../utils/filters.wxs"></wxs>

 

3. In the WXML

 

<view>{{ filters.toFix(price) }}</view>

 

 

 

 

 

 

 

 

 

 

 

 

1

 

Guess you like

Origin www.cnblogs.com/Skate0rDie/p/11275025.html