github地址:https://developers.weixin.qq.com/miniprogram/dev/framework/view/wxs/
js:
Page({
data: {
array: [1, 2, 3, 4, 5, 1, 2, 3, 4]
}
})
wxml:
<view> {{m1.getMax(array)}} </view>
<wxs module="m1">
var getMax = function(array) {
var max = undefined;
for (var i = 0; i < array.length; ++i) {
max = max === undefined ?
array[i] :
(max >= array[i] ? max : array[i]);
}
return max;
}
module.exports.getMax = getMax;
</wxs>