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>
原文地址:https://www.cnblogs.com/mcll/p/11772478.html
时间: 2024-10-09 13:45:46