我在wxml页面中用到了wxs标签,进行过滤时间的操作,岗位各位我过滤后的数据该如何storage存储起来或者是赋值变量
虽然这样写能拿到wxs中的数据,不过需要点击一下,还是建议直接在js中完成过滤操作。
const app = getApp()
Page({
data: {
arr: [1, 2, 3, 4, 5, 6, 7]
},
onLoad() {
},
tmpCallBack(e) {
console.log(e);
}
})
<view wx:for="{{arr}}" wx:key="unique">
<block wx:if="{{tools.filter(item)}}">
{{item}}
</block>
</view>
<view bindtap="{{tools.filterClicked}}">获取过滤数据</view>
<wxs module="tools">
var tmp = [];
function filter(item) {
tmp.push(item);
return true;
}
function filterClicked(event, ins) {
ins.callMethod("tmpCallBack", tmp)
}
module.exports = {
filter: filter,
filterClicked: filterClicked
}
</wxs>