uniapp vue3 setup
使用ref去获取div元素对象,运行到浏览器可以获取到正确的元素。
但是在真机调试到Android手机时,返回的对象是 {pageNode, parentNode, listeners, _text, _html, nodeId, nodeType, nodeName, chiildNodes, attributes, style, vShow}。 应该从哪个字段取到div的scrollTop 或者height
uniapp vue3 setup
使用ref去获取div元素对象,运行到浏览器可以获取到正确的元素。
但是在真机调试到Android手机时,返回的对象是 {pageNode, parentNode, listeners, _text, _html, nodeId, nodeType, nodeName, chiildNodes, attributes, style, vShow}。 应该从哪个字段取到div的scrollTop 或者height
爱豆豆 - 办法总比困难多
你可以使用 获取节点信息的方式 拿到高度或者顶部距离
<template>
<view class="bg">
<button @tap="getDom">按钮</button>
<view class="" id="domId">asdasdasdasd</view>
</view>
</template>
<script setup>
import {
getCurrentInstance
} from "vue"
const instance = getCurrentInstance()
const getDom = () => {
const query = uni.createSelectorQuery().in(instance);
query.select('#domId').fields({
dataset: true,
rect: true,
id: true
}).exec((res) => {
console.log(res)
})
}
</script>
2***@qq.com
那如果是 input,并且我要调用 focus 方法,怎么办
2024-12-10 16:01