<view >我是节点<view>

mounted() {  //获取节点信息,最好在mounted之后获取以确保获取到
    let theNode=uni.createSelectorQuery().select("#iamnode")
    theNode.boundingClientRect((data)=>{
          console.log(data)
    }).exec()
},


注:支持以下选择器
ID选择器:#the-id
class选择器(可以连续指定多个):.a-class.another-class
子元素选择器:.the-parent > .the-child
后代选择器:.the-ancestor .the-descendant
跨自定义组件的后代选择器:.the-ancestor >>> .the-descendant
多选择器的并集:#a-node, .some-other-nodes

注:uniapp目前未发现有效的方法来通过js操作一些dom。比如实现简单的动画效果的需求。
可以通过另外的思路,见:https://www.cnblogs.com/huihuihero/p/14871075.html

uni-app获取dom节点信息简单说明

详细文档请移步至: https://uniapp.dcloud.io/api/ui/nodes-info

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-26
  • 2021-12-04
  • 2021-12-16
  • 2021-10-16
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-05-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案