canvas.boundingClientRect().exec返回null
时间: 2024-04-24 07:27:30 浏览: 16
引用\[1\]中的代码是使用uni-app框架中的createSelectorQuery方法来获取指定元素的位置信息。在这个例子中,使用了select方法选择了id为"scrollview"的元素,并通过boundingClientRect方法获取其位置信息。然而,由于代码中的回调函数中的console.log语句被注释掉了,所以无法确定具体返回的是什么值。但是根据代码中的注释,返回的值可能是null。引用\[2\]中提到了解决这个问题的方法,即使用in(this)来传入自定义组件的实例,以确保能够正确获取到位置信息。引用\[3\]中的代码也是使用了类似的方法来获取元素的位置信息,并在回调函数中进行了相应的处理。所以,如果canvas.boundingClientRect().exec返回null,可能是因为没有正确传入组件实例或者没有正确选择元素。
#### 引用[.reference_title]
- *1* *2* [关于uni.createSelectorQuery().select(el).boundingClientRect 自定义组件获取不到值](https://blog.csdn.net/qq_36639113/article/details/124970523)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [uni-app元素节点操作-uni.createSelectorQuery()](https://blog.csdn.net/weixin_42220130/article/details/129594672)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
相关推荐
![js](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)