微信小程序获取高宽uniapp
代码片段
<template>
<view>
<view class="text" id="w">补充文字</view>
</view>
</template>
<script>
export default {
mounted() {
let query=wx.createSelectorQuery(); //创建节点查询器
query.select("#w").boundingClientRect(); //获取节点位置信息的查询请求
query.exec((res) => {
console.log(res[0])//获取的内容
// id: "w"
// left: 0
// right: 64
// top: 0
// bottom: 21
// width: 64
// height: 21
})
}
}
</script>
<style lang="scss" scoped>
.text{
white-space: nowrap;
display: inline-block;
}
</style>
有问题联系QQ1291481728或在下方评论,会在第一时刻处理。

浙公网安备 33010602011771号