这是微信小程序WXS 使用链接https://developers.weixin.qq.com/miniprogram/dev/framework/view/wxs/
具体使用方法:
1、在wxml中使用
<wxs module="function">
module.exports = {
isDouble:function(n){
return n>9?true:false
}
}
</wxs>
直接在代码段中使用
<view class="overflow flexContent">
{{function.isDouble(item.number)?'双数':'单数'}}
</view>
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
}
<!-- .wxml文件 -->
<!-- 引入 -->
<wxs src="../../utils/filter.wxs" module="filter" />
<!-- 调用 -->
<text>{{filter.strReplace(12345678901)}}</text>