内联写法
<!-- 内联wxs -->
<view>大写字母{{m1.toUpper("xmly")}}</view>
<wxs module="m1">module.exports.toUpper=function(str){return str.toUpperCase()}
</wxs>
外联写法
新建一个wxs文件
写一个函数,将(module.exports)函数共享
function toLower(str){return str.toLowerCase()
}
module.exports={toLower:toLower
}
再在wxml文件中调用
<!-- 外联 -->
<view>小写字母{{m2.toLower("XMLY")}}</view>
<wxs src="/utils/tools.wxs" module="m2" />