1***@qq.com
1***@qq.com
  • 发布:2021-08-16 10:18
  • 更新:2021-10-29 16:48
  • 阅读:849

uni.createSelectorQuery()获取节点高度信息,为什么写在onReady里面也获取不到

分类:uni-app

onReady() {
const query = uni.createSelectorQuery().in(this);
query.select('#scrollItem').fields({size: true,scrollOffset: true}, data => {
console.log("高度啊",data)
}).exec();
},

<view class="swiper " id="scrollItem" v-if="imgUrls.length">
<swiper indicator-dots="true" :autoplay="true" :circular="circular" :interval="interval" :duration="duration"
indicator-color="rgba(255,255,255,0.6)" indicator-active-color="#fff">
<block v-for="(item,index) in imgUrls" :key="index">
<swiper-item>
<navigator :url='item.url' class='slide-navigator acea-row row-between-wrapper ' hover-class='none'>
<image :src="item.pic" class="slide-image "lazy-load></image>
</navigator>
</swiper-item>
</block>
</swiper>
</view>

index.js? [sm]:608 高度啊 null

2021-08-16 10:18 负责人:无 分享
已邀请:
1***@qq.com

1***@qq.com (作者) - uniapp剑港

<view class="swiper " id="scrollItem" v-if="imgUrls.length">
<swiper indicator-dots="true" :autoplay="true" :circular="circular" :interval="interval" :duration="duration"
indicator-color="rgba(255,255,255,0.6)" indicator-active-color="#fff">
<block v-for="(item,index) in imgUrls" :key="index">
<swiper-item>
<navigator :url='item.url' class='slide-navigator acea-row row-between-wrapper ' hover-class='none'>
<image :src="item.pic" class="slide-image "lazy-load></image>
</navigator>
</swiper-item>
</block>
</swiper>
</view>
这是要获取的标签
<view class="swiper " id="scrollItem"

  • 1***@qq.com (作者)

    onReady() {

    const query = uni.createSelectorQuery();

    query.select('#scrollItem').boundingClientRect(data => {

    console.log("高度啊",data)

    }).exec();

    },

    这样也不行

    2021-08-16 10:28

张亚博

张亚博

要把hbuilder重新打开运行

  • 2***@qq.com

    每次都要重新把HBuilder重启一下?

    2023-03-28 15:03

该问题目前已经被锁定, 无法添加新回复