微信小程序在wxml文件中使用函数

这是微信小程序WXS 使用链接https://developers.weixin.qq.com/miniprogram/dev/framework/view/wxs/

具体使用方法:

1、在wxml中使用


      module.exports = {
        isDouble:function(n){
          return n>9?true:false
        }
      }

直接在代码段中使用


     {{function.isDouble(item.number)?'双数':'单数'}}

2、新建一个WXS文件,然后引入

//  .wxs文件
var strReplace = function (value) {  //  *号替换
  value = value.toString();
  var str = '';
  str = value.substring(0, 3) + '****' + value.substring(7, value.length);
  return str;
}
module.exports = {
  strReplace: strReplace
}






{{filter.strReplace(12345678901)}}

 

你可能感兴趣的:(微信小程序,日常问题总结,小程序,WXS,wxml使用函数)