How does vue get the height of the loaded picture?

<div class="file-wrapper">
    <img class="file-position" src="1.jpg" alt="" ref="imgSize" @onload="imgload">
</div>
mounted(){
    this.fileUrl = this.$route.query.file || ""
    //
    let clientHeight = document.documentElement.clientHeight || document.body.clientHeight;
    console.log(clientHeight);
    this.imgload();
},
        
methods:{
    imgload(){
        let imgSize = this.$refs["imgSize"].offsetHeight;
        console.log(imgSize);
    }
}

how do I get the height of the loaded picture (the width and height of the picture is unknown) the value obtained by imgSize is different from the real one?

Apr.07,2022

get the height of the picture after the page has been rendered


mounted(){
    this.$nextTick(() => {
        this.imgload();
    })
}

modify
although the dom above has been loaded, the request for image resources may not have been returned

mounted(){
    doucment.querySelector('flie-position').addEventListener('load', function () {
        this.imgload();
    })
}

I used js to modify the style to implement it. Thank you

Menu