wxs // my-wxs.wxs 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 }
wxml引入
// wxs src 为绝对路径 <wxs src="" module="info" /> <view>{{info.getMax(array)}}</view>