美文网首页
uni-app vue 获取子组件宽高完整代码

uni-app vue 获取子组件宽高完整代码

作者: _菩提本无树_ | 来源:发表于2021-03-26 10:51 被阅读0次
<template>
    <view>
    <commonheader ref="commonheader" class="common" commonTitle="智能作文"></commonheader>
    </view>
</template>

<script>
    
    import commonheader from "@/components/common-header/common-header.vue"
    
    export default {
        data() {
            return {
        commonHeaderHeight:200
            }
        },
        components: {
           commonheader
        },
        onLoad:function(){
            this.$nextTick(function(){
              //获取其他组件也是这个道理
              let query = uni.createSelectorQuery().select('.common');
              query.boundingClientRect(function(data) {
                this.commonHeaderHeight = data.height*2
              }).exec()
          })
        }   
    }
</script>

相关文章

网友评论

      本文标题:uni-app vue 获取子组件宽高完整代码

      本文链接:https://www.haomeiwen.com/subject/prkjhltx.html