[Vuejs]-Bootstrap Vue How to get a height of the card

3👍

You can do a watch on your model.

watch : {
    'modelThatChanges'() {
        var height = document.getElementById("idOfCard").offsetHeight; // includes border and padding
        console.log(height)
    }
}

If this gives an issue that it presents the last value and not the new height. You have to do a Vue.nextTick and it will look like:

watch : {
    'modelThatChanges'() {
        Vue.nextTick(() => {
            var height = document.getElementById("idOfCard").offsetHeight; // includes border and padding
            console.log(height)
        });
    }
}
👤Niels

Leave a comment