当前位置:网站首页>小程序:获取元素节点信息
小程序:获取元素节点信息
2022-07-28 15:44:00 【Ponnenult】
前言:
小程序中,获取元素的节点信息来做一些操作。
我们的pc端获取元素是用
document.getElementById('id名')我们小程序中获取元素的方法
1、创建节点
let query = wx.createSelectorQuery()2、定义对应元素方法 query.select('元素')
query.select('.message-box-list').boundingClientRect(res=>{
//res就是这个元素的信息,在这里做一些操作
this.setData({
scrollTop: res.height
})
})
query.exec(res=>{}) //注意,必须加这个,不然上面的回调函数不会进入注意,小程序获取节点信息如果拿到的内容是null的话
let query = wx.createSelectorQuery().in(this)
边栏推荐
- Splash (rendering JS service) introduction installation
- Learn ABAQUS script programming script in an hour
- The epidemic dividend disappeared, and the "home fitness" foam dissipated
- php关于数据量大导出数据或者遍历数据导致内存溢出超时等问题
- Wake up after being repeatedly upset by MQ! Hate code out this MQ manual to help the journey of autumn recruitment
- Pop up layer prompt in the background
- Wechat official account to obtain material list
- 队列的介绍与实现(详解)
- Two of C language programming!! Role of
- "Wei Lai Cup" 2022 Niuke summer multi school training camp 3 a.ancestor lca+ violence count
猜你喜欢

ANSA二次开发 - Visual Studio Code上搭建ANSA二次开发环境

Ansa secondary development - apps and ansa plug-in management

I can only sell the company after the capital has been "cut off" for two years

flashfxp 530 User cannot log in. ftp

Fx3 development board and schematic diagram

Use js direct OSS to store files in Alibaba cloud and solve the limitation of large file upload server

USB产品(FX3、CCG3PA)的调试方法

视频号找到金钥匙,抖音模仿后来人

Two of C language programming!! Role of

IM即时通讯软件开发网络请求成功率的优化
随机推荐
Leetcode daily practice - 160. Cross linked list
ANSA二次开发 - Apps和ANSA插件管理
ANSYS二次开发 - MFC界面调用ADPL文件
ANSA二次开发 - 抽中面的两种方法
日常开发方案设计指北
Some suggestions on optimizing HyperMesh script performance
PHP image synthesis technology
Use js direct OSS to store files in Alibaba cloud and solve the limitation of large file upload server
flashfxp 530 User cannot log in. ftp
Sort 1-insert sort and Hill sort
Leetcode topic
“蔚来杯“2022牛客暑期多校训练营3 A.Ancestor LCA+暴力计数
Fx3 development board and schematic diagram
Several methods of HyperMesh running script files
"Wei Lai Cup" 2022 Niuke summer multi school training camp 3 a.ancestor lca+ violence count
IM即时通讯开发优化提升连接成功率、速度等
PHP about problems such as memory overflow timeout caused by large amount of data exporting or traversing data
Sort 5-count sort
Splash (渲染JS服务)介绍安装
2021-04-02
