小程序过滤器

wxs

https://developers.weixin.qq.com/miniprogram/dev/framework/view/wxs/

<!--wxml-->
<wxs module="m1">
var msg = "hello world";

module.exports.message = msg;
</wxs>

<view> {{m1.message}} </view>
1
2
3
4
5
6
7
8
<!--wxml-->
<wxs src="./index.wxs" module="utils"></wxs>
<view>{{ utils.stringify({name:'zs'}) }}</view>
1
2
3
// wxs
function stringify(val) {
  return JSON.stringify(val)
}
module.exports = {
  stringify: stringify,
}
1
2
3
4
5
6
7