QQ/微信小程序中用自设的.qml(.wxml)模板中具有“{{ }}“动态的代码,调用后不执行(在检查器中无法显示)。如何解决?
<view>
<wxs module="fn1">
module.exports = {
toShowNumber: function(value) { //优化大数字展示
if (value > 100000000) {
var t = value / 100000000;
return t.toFixed(3) + '亿';
} else if (value > 10000) {
var v = value / 10000;
return v.toFixed(2) + '万';
} else {
return value;
}
},
toSplit: function(value) { //字符串拆分
return value.split('_');
}
//等等
}
</wxs>
<!-- 使用 -->
<view>
<text>人口:{{fn1.toShowNumber(1122334)}}</text>
</view>
<view>
<text>地区:{{fn1.toSplit('中国_浙江_杭州')}}</text>
</view>
<view>
<text>省会:{{fn1.toSplit('中国_浙江_杭州')[1]}}</text>
</view>
</view>