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

2021-03-26  本文已影响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>
上一篇下一篇

猜你喜欢

热点阅读