1、页面上直接写脚本
<!-- 引入wxs脚本 -->
<wxs module="tools">
var random=function(){
return Math.random()
}
module.exports.random = random;
</wxs>
需要的地方加载以下代码
<image src="{{fileUrl}}/pic.png?v={{tools.random()}}"></image>
2、页面引入utils文件夹中的aa文件,需要用的地方再加载
<wxs src="../../utils/aa.wxs" module="tools" />
网友评论