9***@qq.com
9***@qq.com
  • 发布:2019-04-27 10:42
  • 更新:2020-08-11 10:09
  • 阅读:15030

uni.createSelectorQuery().in(this).select('#els').boundingClientRect().exec

分类:uni-app

uni.createSelectorQuery().in(this).select('#els').boundingClientRect().exec(res=>{}) 这个res在h5+app里到底是啥 还是没有的 感觉根本没取到元素······

uni.createSelectorQuery().select("#els").boundingClientRect() 按文档上的写会报错 是文档太烂 还是在隐藏什么 app好多东西不行 感谢你们的开源坑 ps:可能只是我太菜!!!

2019-04-27 10:42 负责人:无 分享
已邀请:
9***@qq.com

9***@qq.com (作者)

这东西在手机里根本就获取不到元素,然后执行后续逻辑错误,也不报错,,所以获取宽高之类的元素还是用'auto'或百分比之类的吧

  • 1***@163.com

    应该是bug,我试过也获取不到,应该是bug,你提交bug叫官方修改


    2019-04-27 12:00

1***@qq.com

1***@qq.com - 热爱生活,热爱编程,热爱学习!

可以在
created()
{
this.getDataList();//页面数据渲染完成后,把你需要获取的dom元素节点的方法放在下面即可
this.$nextTick(() => {
//执行dom获取动态dom节点的方法
})
}

gank_li

gank_li

这个bug现在还没修复。。。。。支付宝小程序获取不到的,都是undefined

  • 1***@qq.com

    我真是服,现在还没修复


    2020-06-22 15:27

人物略有不同

人物略有不同

确实不能用。按文档走都行不通。。。。
官方一直没有解决,很是头痛

7***@qq.com

7***@qq.com

<template>  
	<view class="content">  
		页面 - 1  
		<swiper :indicator-dots="true" :style="{height:he+'px'}" :autoplay="true" :interval="3000" :duration="1000">  
			<swiper-item>  
				<view class="swiper-item">  
					<image src="../../../static/img/video.png" mode="" :id="elId"></image>  
				</view>  
			</swiper-item>  
			<swiper-item>  
				<view class="swiper-item">  
					<image src="../../../static/img/tabbar/addactive.png" mode=""></image>  
				</view>  
			</swiper-item>  
		</swiper>  
	</view>  
</template>  
  
<script>  
export default {  
	data() {  
		const elId = `Uni_${Math.ceil(Math.random() * 10e5).toString(36)}`  
		return {  
			title: 'Hello',  
			elId: elId,  
			he:'',  
		};  
	},  
	onShow() {  
		 uni.createSelectorQuery().in(this).select(`#${this.elId}`).boundingClientRect().exec((ret) => {  
		 	if(ret[0]){  
		 		// this.height = ret[0].height + 'px'  
				console.log(ret[0].height)  
				this.he=ret[0].height  
		 	}  
		 });  
	},  
	methods: {}  
};  
</script>  
  
<style>  
.content {  
	text-align: center;  
	height: 400upx;  
	margin-top: 200upx;  
}  
</style>  

倒影

倒影 - 记忆的时间差.

我也获取不到,时不时的获取到的是null

  • 最菜的韭菜

    对,我也是,页面不滑动可以获取到,页面滑动就获取不到了,h5是可以获取到,但是app获取不到,唉


    2020-02-17 20:19

1***@qq.com

1***@qq.com

我试过可以获取到,不过异步数据就不行,可以参考hello项目里面的懒加载案例

8***@qq.com

8***@qq.com - test

加个延时就可以获取到了

邱泽贤

邱泽贤 - uniapp开发

加一个yanshi就ok了

LOOKINGFFuture

LOOKINGFFuture

获取不到的问题请看下vue执行的生命周期以及uniapp的执行生命周期

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