官网:https://developers.weixin.qq.com/miniprogram/dev/api/wxml/SelectorQuery.html
注意里面的 in(this) ,这个this是说明获取那个组件,一般写自身即可
select("#this-id") : 这个是获取单个的,你可以获取多个即可 selectAll
括号内的是选择器,当然你可以是其他详细看文档即可
如果是组件内获取,组件里面 推荐在 监听器后面写。
PS : 如果一直为空和null,推荐吧res改为 rects ,不知道为什么...
还可以获取其他信息,例如视图、滚轮高度什么的 详细看文档:
https://developers.weixin.qq.com/miniprogram/dev/api/wxml/wx.createSelectorQuery.html
作者:咸瑜